Skip to content
Work

Streaming system design

Real-Time Fraud Detection

High-throughput real-time decisioning

A streaming architecture that scores transactions in flight — ingest, feature computation, model inference and decisioning on the hot path, with everything durably landed for analysis and retraining.

Period
2025
Status
Design + implementation study
Stack
Kafka · Stream processing · Python · Feature store · Lakehouse · Kubernetes · Observability

Simplified data flow

  1. 01TransactionsProducers emit keyed events
  2. 02KafkaPartitioned by account for ordering
  3. 03Stream processingWindowed aggregates, enrichment
  4. 04FeaturesLow-latency online feature reads
  5. 05InferenceModel scores the enriched event
  6. 06DecisionAllow · review · block
  7. 07Alerts + LakehouseOperators and offline analysis

10M events/sec

Design target — not measured

Per-account

Ordering guarantee

Rules fallback

Degradation path

01Overview

Fraud decisioning is a latency problem wearing a machine-learning costume. The model matters, but the engineering question is how to get a correct, enriched feature vector to that model within a few tens of milliseconds while the transaction is still waiting — and to do it under bursty load without dropping or double-counting events.

02Problem

A decision made after the transaction settles is an incident report, not a control. The system has to consume a high-rate transaction stream, compute behavioural features over recent history, score, and return a decision inside the payment path — while remaining correct when a consumer restarts mid-window.

03Goals

  • Decision on the hot path, within the payment authorisation budget.
  • Ordering guarantees per account so behavioural windows are correct.
  • Graceful degradation: a slow model must not stall ingestion.
  • Every event and every decision durably landed for audit and retraining.
  • Horizontal scale by partition, with no single-node bottleneck.

04Architecture

Ingestion

Kafka topics keyed by account id. Partition count sets the maximum parallelism and guarantees per-account ordering.

Stream processing

Stateful operators maintain windowed aggregates per key — velocity, amount deviation, geo/device change — with checkpointed state.

Feature access

Streaming features are combined with slow-moving profile features read from a low-latency online store.

Inference

Model served behind a bounded-concurrency call with a strict timeout and a deterministic rules fallback.

Decisioning

Score plus policy rules produce allow / review / block, emitted to a decisions topic consumed by the payment path and by alerting.

Lakehouse

Raw events, computed features and emitted decisions are written to the lakehouse so training data matches what the online path actually saw.

05Data flow

A transaction is produced to Kafka keyed by account. A stream processor consumes the partition, updates windowed state for that account, and enriches the event with online profile features. The enriched vector is scored; the score and policy rules produce a decision that is emitted to a decisions topic within the authorisation window. In parallel, the raw event, the exact feature vector used, and the decision are appended to the lakehouse — so the offline training set is the online reality rather than a reconstruction of it.

06Engineering challenges

Training/serving skew

If offline features are recomputed with different logic from the online path, the model is evaluated on data it will never see. Persisting the exact feature vector used at decision time removes the reconstruction step entirely.

Hot partitions

Keying by account gives ordering, but a small number of very active accounts can skew a partition. Partition count and key salting for known-hot keys are the levers; both cost some ordering guarantees, which is a deliberate trade.

Exactly-once-enough semantics

True end-to-end exactly-once is expensive. Decisions carry an idempotency key derived from the transaction id, so at-least-once delivery plus idempotent consumers gives the property that actually matters.

The model is the slowest component

Inference is bounded by concurrency and a hard timeout. On timeout the system falls back to deterministic rules rather than blocking the stream — a worse decision beats no decision inside a payment path.

07Decisions & trade-offs

Partition by account, not round-robin

Why Behavioural windows are per-account; ordering within a key is what makes velocity features correct.

Alternative Round-robin for perfect balance — better distribution, unusable window semantics.

Streaming aggregates over on-demand queries

Why Querying a store per transaction pushes tail latency into the payment path and load onto the store.

Alternative Compute features at request time — simpler, does not survive peak load.

Rules fallback in front of the model

Why Availability of a decision is a hard requirement; model availability is not.

Alternative Fail the transaction on model timeout — safer for fraud, hostile to legitimate users.

Lakehouse as the single analytical landing zone

Why One append-only substrate for events, features and decisions keeps audit and retraining consistent.

Alternative Separate stores per concern — faster per use case, divergent truth over time.

08Reliability

Consumer state is checkpointed, so a restart resumes from the last committed offset and rebuilds window state rather than silently losing it. Model timeouts degrade to rules; a downstream outage backs pressure into Kafka retention instead of dropping events.

09Scale

Throughput scales with partition count and consumer instances. The design target is 10M events/sec — this is a design target used to drive partitioning, state sizing and back-pressure decisions, not a measured production benchmark.

10Quality

Correctness is checked at three points: schema contracts on ingestion, invariants on windowed state, and reconciliation between the decisions topic and the lakehouse to confirm no decision is lost between the online and offline views.

11Outcome

The result is an architecture where latency, ordering, correctness and failure behaviour are each an explicit decision with a stated trade-off. All figures are design targets from the system design; this is an engineering study, not a deployed production service.

Next case study

AURYNT Data Factory