Skip to main content

Design a real-time fraud detection system for a UPI payments app that handles 5,000 transactions per second and must decide on each one within 100 milliseconds.

System design · Pro 2

Short answer

Clarify the allowed actions (approve, step-up check, block), the latency budget and the cost of each error. Then: a stream pipeline computing velocity features per user, device and merchant, a low-latency feature store, a gradient-boosted model beside rules, thresholds set by cost, late labels from chargebacks, shadow mode first, and monitoring for drift.

Deeper answer

Start with requirements: which actions are allowed, how much friction a false positive causes, and how much money a missed fraud costs. Labels arrive late, from chargebacks and user reports, often weeks after the payment. Fraud is a very small share of traffic, so the data is heavily imbalanced.

Data flow: each payment event goes to a stream processor that updates velocity features, such as payments in the last minute per device, new payees today, and the amount compared with the user's history. The scoring service reads these from an in-memory store, adds request features, and runs a gradient-boosted model beside hard rules. Scores map to approve, step-up authentication or block. Borderline cases go to a review queue, which also produces labels.

Trade-offs: graph features and larger models can raise recall but put the latency budget at risk, so heavy features are computed asynchronously. Evaluate offline with precision and recall at a fixed false positive rate on a time-based split, then run in shadow mode before taking real decisions. At scale, the tail latency of the feature store breaks first, and blocked payments give no label, which biases later training.

What a strong answer covers

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

ML interviews

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.