Building a Real-Time Fraud Detection Pipeline
Modern financial crime moves faster than traditional batch processing can handle. When unauthorized card-not-present transactions or synthetic identity takeovers occur, detecting the anomaly six hours
Published 10/24/2026 · Izan Technologies
Want this built for your team?
Senior engineers, your cloud, your IP.
Modern financial crime moves faster than traditional batch processing can handle. When unauthorized card-not-present transactions or synthetic identity takeovers occur, detecting the anomaly six hours later in an overnight batch job is effectively an operational post-mortem. Mitigating financial loss requires shifting from reactive auditing to sub-second intervention. Implementing a resilient production system capable of flagging or blocking malicious activity demands deep expertise in streaming & real-time data pipelines, distributed stateful processing, and low-latency machine learning inference.
Designing an enterprise pipeline for real time fraud detection requires balancing accuracy against strict latency constraints. An automated fraud engine must evaluate incoming card swipes, wire requests, or checkout events, compute streaming features across variable time windows, query historical profiles, score the event using an ML ensemble, and trigger an automated decision—all within a typical budget of 50 to 100 milliseconds.
Here is a blueprint for building real time fraud mitigation infrastructure capable of processing tens of thousands of transactions per second on enterprise cloud stacks.
High-Throughput Event Ingestion and Message Brokering
The bedrock of any streaming architecture is a decoupled, horizontally scalable ingestion tier. Financial events must be captured reliably without data loss, even during sudden transaction spikes on high-volume shopping days.
[Client / POS / Gateway]
│
▼ (HTTPS / gRPC)
[API Gateway / Ingress]
│
▼
[Distributed Log: Kafka / Kinesis / Event Hubs]
┌────┴────────────────────────┐
▼ ▼
[Stream Engine: Flink/Spark] [Raw Lake Storage]
Most enterprise architectures rely on Apache Kafka, AWS Kinesis, or Azure Event Hubs as the central log. For optimal throughput and deterministic partitioning, partition keys should be mapped to the primary entity evaluated for fraud—typically an account_id, card_id, or device_fingerprint.
- Partitioning Strategy: Correct key selection guarantees that events associated with the same account arrive in strict chronological order on the same partition. This avoids distributed race conditions during state evaluation.
- Compression and Serialization: High-throughput systems leverage binary serialization formats like Apache Avro or Protocol Buffers (Protobuf) backed by a Schema Registry. This minimizes payload size, preserves strict schemas, and eliminates parsing overhead compared to standard JSON.
Distributed Stream Processing and Stateful Windowing
Stateless checks (such as verifying whether a single transaction exceeds $10,000) are trivial. The actual signal for fraud lies in stateful context:
- Velocity: Has this card been used 5 times in the last 60 seconds across different merchant IDs?
- Geographic Impossibility: Was a physical card present in Chicago, followed by a charge in London 12 minutes later?
- Deviation from Norm: Does this single purchase represent a 400% deviation from the rolling 30-day average transaction amount for this user?
Computing these metrics in-flight requires a stream processing engine like Apache Flink, Spark Structured Streaming, or Databricks Streaming Engine.
[Kafka Ingestion Stream]
│
▼
[Keyed Stream (by account_id)]
│
┌──────────────┴──────────────┐
▼ ▼
[Sliding Window: 5 Min] [Tumbling Window: 1 Hr]
Velocity: Count = 6 Aggregate Volume = $2,400
│ │
└──────────────┬──────────────┘
▼
[Enriched Event with Real-Time Features]
Flink is frequently preferred for ultra-low latency due to its native pipelined execution model (event-at-a-time processing) and native RocksDB-backed state storage. RocksDB manages out-of-core state on local NVMe drives while periodically taking asynchronous checkpoints to object storage (Amazon S3, Azure Data Lake Storage), ensuring exactly-once processing semantics without stalling event throughput.
Architectures for Real-Time Inference: Choosing the Right Paradigm
When integrating machine learning scoring into the event stream, engineering teams must weigh latency, system complexity, and infrastructure overhead.
| Architecture Pattern | End-to-End Latency | Operational Complexity | Fault Isolation | Best Use Case |
|---|---|---|---|---|
| In-Stream Embedded Model (ONNX / PMML inside Flink/Spark workers) | Lowest (< 15ms) | High | Poor (model memory leaks or crashes take down data pipelines) | Pure inline classification; single-tenant or strict sub-20ms SLAs |
| Decoupled Microservice (RPC to Triton, Ray Serve, or SageMaker) | Moderate (30–60ms) | Moderate | High (model tier scales independently from ingestion) | Heavy ensembles (XGBoost + Transformers); complex business rule layers |
| Dual-Path / Shadow Architecture (Rule engine inline, async ML pipeline) | Hybrid (< 20ms inline, async ML) | High | High (fallback rules safeguard pipeline stability) | Graceful degradation; compliance-heavy banking environments |
For most enterprise implementations, a decoupled microservice or specialized inference server running on Triton or TorchServe provides the best trade-off between deployment agility and blast-radius management.
Constructing the Latency Budget
To maintain an end-to-end SLA of less than 80 milliseconds, each step in the pipeline must operate within a deterministic latency budget:
- Ingress & Ingestion (5–10ms): Network transit to API gateway and ingestion into the distributed streaming log.
- Stream Enrichment & Aggregations (10–15ms): Event consumption, keying, RocksDB state lookups for sliding windows, and emission of enriched payloads.
- Feature Store Lookup (5–12ms): Pulling offline-computed baseline aggregations (e.g., 90-day merchant risk scores or historical baseline behavior) from high-speed distributed caches like Redis, Amazon ElastiCache, or Snowflake-fed Feast/Hopsworks stores.
- ML Model Scoring (15–25ms): Concurrent evaluation across an ensemble—typically a fast Gradient Boosted Decision Tree (LightGBM/XGBoost) combined with a deep learning isolation forest or graph-embedding model.
- Decision Matrix & Action Dispatch (5–10ms): Rule evaluation combining ML probability scores with deterministic compliance rules (e.g., OFAC sanction checks) and returning an
APPROVE,FLAG, orDECLINEstatus.
Overcoming Training-Serving Skew with Centralized Feature Stores
A common failure mode in real time fraud detection systems is training-serving skew. This occurs when the feature definitions used to train models offline in batch warehouses (like Databricks or Snowflake) do not mathematically match the streaming feature definitions calculated on the wire.
┌─────────────────────────┐
│ Central Feature Store │
│ (Feast / Hopsworks) │
└────────────┬────────────┘
│
┌───────────────────────┴───────────────────────┐
▼ ▼
[Offline Store: Snowflake/Databricks] [Online Store: Redis]
- Batch Features (90-day avg) - Low-Latency Reads (<5ms)
- Model Training Datasets - Real-Time Inference Ingestion
A modern feature store reconciles this discrepancy:
- Online Serving Layer: Stores recent values in low-latency key-value stores (Redis, DynamoDB) for sub-5 millisecond lookups during live scoring.
- Offline Historical Layer: Automatically syncs identical values into columnar storage (Delta Lake on Databricks, Snowflake Dynamic Tables) for reproducible point-in-time training joins.
When an engineer modifies a feature like std_dev_transaction_amount_7d, the logic is deployed once to the feature store registry, generating both the streaming transformation and the historical backfill automatically.
Cloud-Native Implementation Patterns: AWS, Databricks, and Snowflake
Enterprises rarely build streaming pipelines on bare metal today. Modern cloud platforms provide robust foundations:
Databricks on AWS/Azure
Using Databricks Structured Streaming alongside Delta Live Tables (DLT) provides an efficient data curation pattern. High-throughput inputs are landed into a Medallion Architecture. Bronze tables capture raw Kafka feeds; Silver tables execute watermarked aggregations and sliding-window velocity counts; Gold tables surface inference logs. MLflow orchestrates model registry lifecycles, compiling tree ensembles to ONNX runtimes for deployment.
Snowflake Streaming & Dynamic Tables
For organizations centralized around Snowflake, Snowpipe Streaming enables low-latency rowset ingestion straight into staging tables. Combined with Dynamic Tables for near-real-time materialized views, fraud analysts can query live threat vectors without building bespoke operational data stores, bridging the gap between analytics and real-time operations.
Engineering for Resilience: Backpressure, Watermarks, and Cold Starts
Building real time systems requires engineering for inevitable downstream failures:
- Watermarking and Late-Arriving Data: Network drops on mobile POS terminals mean transactions can arrive out of order. Establishing explicit watermarks (e.g., tolerating up to 30 seconds of late arrival) ensures stream aggregations close deterministically without holding unbounded memory allocations.
- Graceful Degradation: If the primary ML inference service experiences a timeout, the pipeline must fail open or fall back to an embedded heuristic rule engine rather than hanging the payment gateway.
- State Cold Starts: If a stream processor restarts, reloading gigabytes of windowed state from remote storage can stall processing. Employing incremental state checkpointing and localized persistent volumes ensures workers recover within seconds.
How Izan Technologies helps
Designing, scaling, and operationalizing real time fraud engines requires senior-level systems engineering. Izan Technologies designs and builds custom AI, machine learning, and data engineering architectures on AWS, Azure, Databricks, and Snowflake.
Unlike vendors who lock you into black-box SaaS applications or retain proprietary rights to components, Izan Technologies ensures our clients own 100% of the intellectual property we deliver. You get battle-tested, high-performance streaming architectures and custom models that remain permanent, proprietary enterprise assets for your organization.
Ready to architect your streaming analytics and real-time inference infrastructure? Try our Smart AI DataStudio or talk to an expert today.
Want this built for your team?
Senior engineers, your cloud, your IP.