One card, one Tuesday evening, as the payment processor's logs recorded it. The card's number, expiry date and security code had been copied from a hacked online shop and sold an hour earlier. Every attempt came from the same laptop, at a different merchant each time:
- 21:14:03, US$1.00 to a charity's donation page. Approved.
- 21:14:09, US$1.00 to a second donation page. Approved.
- 21:14:15, US$2.50 to a music streaming service. Approved.
- 21:14:22, US$0.99 to a mobile game. Approved.
- 21:14:30, US$4.00 to a parking app. Approved.
- 21:14:38, US$89 to a clothing shop. Approved.
- 21:14:44, US$240 to a shoe shop. Approved.
- 21:14:50, US$480 to an electronics shop. Approved.
- 21:14:55, US$620 in gift cards. Approved.
- 21:15:01, US$910 to a second electronics shop. Approved.
Ten payments in 58 seconds, US$2,348.49 in all. The first five are card testing: tiny amounts at merchants that ask few questions, to learn whether the stolen card works before spending it. The last five are the spending. The cardholder found them the next morning, called her bank, and over the following weeks each payment came back as a chargeback, the card system's way of reversing a payment the cardholder disputes.
The processor in this story is fictional, like the card, the merchants and every amount. It sits between thousands of online merchants and the card networks: a shopper pays, the merchant's checkout hands the card to the processor, and the processor forwards the payment towards the bank that issued the card. Before forwarding it, the processor is supposed to decide whether the payment looks like fraud. That evening it had to make that decision ten times about the same card, and each time it looked at one payment as if it were the only one.
That decision is what this post designs, and it has a hard limit: it happens while a shopper is looking at a spinning button. The processor gives it 100 milliseconds. Everything that follows, from rules to a model, is paid for out of those 100 ms, and the analysts who arrive last work in time the budget does not count. Each new part has to say how many milliseconds it spends and what happens when it is late. The answer to the second question never changes: when a part of the fraud check is slow or broken, that failure alone never declines a payment.
A busy evening, in round numbers
Every number below is an assumption of the exercise, rounded so the arithmetic is easy to follow. None is a measurement of a real processor, card network or fraud model, and none is a rule any card network sets:
- About 50 million card payments a day. The day has a shape: two busy evening hours at about 2,000 a second (7.2 million an hour), twelve daytime hours at about a third of that (about 670 a second, 2.4 million an hour) and ten night hours at about 190 a second (about 680,000 an hour). That adds up to 14.4 + 28.8 + 6.8 = 50 million.
- About 0.1% of payment attempts are fraudulent, about 50,000 a day, about two a second in the busy hours. The other 99.9% are people buying things.
- The risk decision must never take more than 100 ms, measured from the moment the payment service asks to the moment it has the answer. The payment service enforces that as a hard timeout, so the design does not plan to use it all: it aims for the decision's 99th percentile to sit far below 100 ms, so that the timeout is almost never what answers. The checkout waits longer than that in total, because the card network and the issuing bank take their own share of the time; this post is only about the processor's share.
The payment itself gets one paragraph here. When the shopper pays, the payment service sends an authorization request through the card network to the issuing bank, which checks the card and the cardholder's available money and answers yes or no. A yes puts a hold on the money; nothing has moved yet. The merchant claims it later with a capture: a shop selling physical goods often captures when it ships, a day or two later, while a shop selling something delivered at once, such as a gift card code, captures straight away. A cardholder who did not make a payment can dispute it with the bank, and weeks later that dispute arrives back as a chargeback. Payments & billing integration follows a payment through those states. For online card payments, the cost of a fraudulent payment usually lands on the merchant, though who pays depends on the network's rules and on whether the shopper was authenticated, so a processor whose merchants keep paying chargebacks soon loses them.
The issuing bank makes its own fraud decision when the authorization reaches it, and that evening it approved all ten payments too. The processor's decision is a second, independent look, made with something the issuer does not have: the device, the IP address and every card, from any bank, tried at the processor's thousands of merchants.
Rules that judge one payment at a time
The first version is the smallest one that can say no. Before forwarding a payment to the card network, the Payment service sends it to a Risk service and waits for one of two answers, approve or decline. The risk service holds a set of hard rules in memory:
- A blocklist of cards already reported stolen to the processor, by card fingerprint (a keyed hash of the number, so the list itself holds no card numbers).
- Amount limits per kind of merchant: say, no single online payment above US$5,000 at an electronics shop, or above US$1,000 in gift cards.
- Blocked card ranges and countries: card number ranges a fraud team has seen abused, and card countries none of the processor's merchants sell to.
Rules are fast and easy to explain. Checking a payment against them is a few lookups in memory, well under a millisecond, and when a merchant asks why a payment was declined, the answer is one sentence. The budget for this version, as a budget and not a measurement:
- Network round trip, payment service to risk service and back: about 2 ms, both in the same data centre.
- Hard rules: about 1 ms, rounded up.
- Total: about 3 ms of the 100. The other 97 are unused.
The risk service sees one payment, and only that payment.
Learn morePayments & billing integrationLatency percentiles & tail latencyTimeout
Now run the Tuesday evening through it. The card was stolen an hour earlier, so it is not on the blocklist. Every amount is below every limit. The card is domestic and so are the merchants. Each of the ten payments, looked at alone, is ordinary: people do donate a dollar, buy a game, pay for parking and order shoes. All ten are approved in about 3 ms each.
What gave the card away was not any one payment. It was the sequence: ten merchants in a minute, tiny amounts and then large ones, all from one laptop. A rule that looks at one payment cannot see a sequence, and tightening the rules does not help. Lower the electronics limit to US$400 and the thief buys US$390 items, while every honest customer buying a US$600 phone is declined. Each rule tight enough to catch this card would also decline good payments like that phone, every day.
What happens when the risk service is slow or down? The payment service calls it with a timeout of 100 ms. If the call fails quickly, say the connection is refused, it retries once on another instance, which fits easily in the budget. If there is still no answer when the 100 ms run out, the payment service forwards the payment unscored and records that it did; the issuer still makes its own decision. That is a choice made in advance, and it is the first appearance of this design's rule: missing the fraud check costs some fraud, but failing a good payment because the fraud check is down costs the sale and, often, the customer. Every unscored payment is counted, and a rising count pages whoever is on call. Timeout covers choosing the number, and Latency percentiles & tail latency why the plan is made on the 99th percentile rather than the average.
The card's last minute, counted beside the decision
The risk service needs to know, at decision time, what this card, this laptop, this IP address and this merchant have been doing over the last minutes and hours. The numbers that answer that are called velocity features: how many payments this card made in the last 60 seconds, at how many different merchants, how much it spent in the last hour, how many different cards this laptop has used today, how many small payments this merchant received from cards it had never seen before in the last ten minutes.
The obvious place to get them is the payment service's own database, which records every payment. That fails on arithmetic. Each decision needs about six such numbers, each one a query that counts or sums rows over a time range. At 2,000 decisions a second, that is 12,000 aggregate queries a second against the database that also has to record every payment. Some of them are heavy: a merchant running a sale at 50 payments a second has 30,000 rows in its last ten minutes, and the query that counts them runs for every one of its payments. A query like that is fine at a few a second and unpredictable at thousands, and an unpredictable query is exactly what a 100 ms budget at the 99th percentile cannot afford.
So the work moves off the decision path. The payment service now also publishes every payment to Payment events, a durable event stream, once the risk decision has been made and whatever its outcome: a declined attempt is still an attempt. A stream processor reads that stream and keeps running counts and sums per card, per device, per IP address and per merchant, over sliding windows of a minute, ten minutes, an hour and a day, kept as small time buckets. That job, Velocity windows (the velocity job from here on), writes the buckets to Online features, a key-value store that serves features at decision time (online, as opposed to the history kept for training) and answers one lookup in a millisecond or two. The risk service reads every key it needs, card, device, IP and merchant, in one round trip, and sums only the buckets still inside each window, so a card that goes quiet sees its count fall without anything being rewritten.
The counting happens beside the decision; the decision only reads the results.
Learn moreStream processing: windows, watermarks & stateCounting at scale
The cost is freshness. A payment's event is published after the decision, then read and counted by the velocity job, then written to the store. Assume that path takes about one to two seconds when all is well. The features the risk service reads are therefore always slightly behind, and one payment is never in them: the one being decided. So the risk service adds it to what it read. The store keeps which merchants the card used, not just how many: if it lists three in the last 60 seconds and the current payment is at a merchant not on that list, the decision works with four.
The rules can now look at sequences. Add one: a card used at four or more different merchants within 60 seconds is declined. Replay Tuesday. The first three attempts, at 21:14:03, 09 and 15, are approved; each was counted within two seconds. At 21:14:22 the store says three merchants in the last minute, the current payment makes four, and the mobile game is declined, along with the six attempts after it. The thief spends US$4.50 instead of US$2,348.49.
The budget grows by one round trip:
- Network round trip to the risk service: about 2 ms.
- Read the velocity features for card, device, IP and merchant, in one round trip: about 5 ms at the 99th percentile.
- Hard rules and velocity rules: about 1 ms.
- Total: about 8 ms of the 100.
Counting has its own traps. If the payment service publishes an event twice, after a retry for instance, a naive counter counts the payment twice, and a card becomes suspicious for a payment it made once. So the velocity job keys its window state by payment id and ignores an id it has already seen in the window. Stream processing: windows, watermarks & state covers windows and state that survives a restart, Counting at scale keeping many counters both fast and right, and Idempotency & exactly-once illusions why “process each event once” is a property the design builds, not one it gets for free.
What happens when the velocity job falls behind? A slow deployment, a crashed worker, one slice of the stream receiving far more events than the others: the job is still reading, but 50 seconds late. Replay Tuesday with that lag. At 21:15:01, the tenth attempt, the store has counted only what happened up to 21:14:11: the first two donations. With the current payment added, the risk service sees three merchants in a minute, the rule needs four, and the US$910 electronics order is approved, like every attempt before it. Lag turns the tenth attempt into the third. Two defences, and both have a cost:
- Watch the lag itself. The velocity job reports how far its newest counted event lags behind the present, and an alert fires at ten seconds.
- Keep one counter out of the stream's hands. On every decision, the risk service itself records the payment's id and time in a small per-card list in the online store, dropping entries older than two minutes, adding the new one and counting in one atomic step, in the same round trip as the other features. Ids, rather than a plain counter, so that a retried decision does not count the payment twice. It costs one more write per decision, about 2,000 a second in the busy hours, and it answers only the simplest question, how many attempts this card made in the last two minutes, but that question does not depend on the stream: with a rule of four attempts in two minutes on it, the Tuesday card is declined at its fourth attempt whatever the lag. When the lag passes 30 seconds, the risk service also tightens its rules for the riskiest patterns, such as gift cards bought from a device the card has never used, and accepts that some good customers are declined until the velocity job catches up.
And when the online store is down? The risk service decides without features, which is the first stage again: hard rules only, about 3 ms, more fraud approved, every such decision counted. The feature read has its own deadline of 8 ms, so a stuck store costs at most that, and the store's absence declines nothing.
And when the event stream is down? The payment service publishes after the decision and never makes the authorization wait for the stream: what it cannot publish, it buffers locally and retries. The velocity job receives nothing new until publishing resumes, and then works through the replayed backlog, so to the decision path a stream outage looks like lag, with the same answer: the risk service's own two-minute set keeps counting attempts per card, while the counts per device, IP address and merchant stand still. Events lost with a crashed instance's buffer never reach the windows, and decisions already made are not revisited; a reconciliation against the payment service's own record of payments counts what was lost.
And a big sale? Traffic doubles for an evening. The decision path only reads values that are already computed, so it scales by adding risk service instances, which hold no state. The stream absorbs the burst, and the velocity job scales separately; if it cannot keep up, what the decision path sees is lag, and lag already has an answer.
One cost remains, and it is not technical. Booking a holiday through a travel site that charges the airline, the hotel, the car hire and the travel insurance as four separate merchants is four merchants in a minute too, and the new rule declines the family doing it.
The thief slows down, and rules run out
Two weeks later the ring behind the Tuesday card has learned the rule. A new stolen card is tested three times over twenty minutes, one small payment at a time, never twice in the same minute. Then, from a laptop the card has never been used on, at a merchant category this cardholder has never bought from, comes a US$640 gift card purchase. Four merchants in a minute: no. Any limit broken: no. Approved.
More rules could catch it: three payments under US$5 in half an hour followed by one above US$300. Each such rule has a threshold the ring will find, and each one declines someone: three parking payments and a pair of trainers is a normal afternoon. What gives this card away is a combination: small payments then a large one, a device the card has never used, a merchant category the card never buys from, a card that, in the processor's records, buys groceries in one city. Weighing dozens of signals at once, against what past fraud and past honest payments looked like, is what a trained model does.
So the risk service now asks a Fraud model for a score between 0 and 1, higher meaning more likely fraud, computed from the same online features the rules read, including some slower-moving ones the velocity job also keeps, such as the merchant categories and cities each card has used over the last 90 days. The rules still run first, and they keep the last word on hard limits: a blocklisted card is declined whatever its score, and no score approves a payment above a limit. Between the rules, the model decides with one threshold, an assumption of the exercise: a score of 0.8 or more is declined, anything lower approved. In this story, the gift card payment scores 0.93 and is declined, while the family booking a holiday, on the laptop and at the kind of merchants the card has used for years, scores low and is approved. The velocity counts become model inputs, and the hard rules keep only their extremes: ten merchants in a minute, and ten attempts in two minutes on the risk service's own count. While the model is unavailable, the second stage's thresholds of four come back.
Models of the kind often used for this, built from many small decision trees over dozens of numeric features, walk their trees on an ordinary CPU in well under a millisecond; the call around them, from receiving the request to sending the score, costs more. Assume, generously, about 8 ms of one CPU core per call, everything included: one core then scores about 125 payments a second, the busy hours need about 16 fully busy cores, and a fleet of about 50 cores across several replicas keeps them well below full use, where slow calls stay rare, with room for a sale. Model serving: inference, versions & safe rollout covers running such a service and putting a new version in front of real payments safely.
The budget for this stage:
- Network round trip to the risk service: about 2 ms.
- Read the online features: about 5 ms.
- Rules: about 1 ms.
- Model call: a deadline of 30 ms, less than a third of the 100 ms timeout. A healthy call returns well before it.
- Total: a planned budget of about 38 ms. The remaining 62 ms are headroom, not spare budget for a slower model.
Why keep 62 ms unused? Adding up each step's budget, as the list does, is a plan rather than a proof: the slow moments of different steps do not line up neatly, and a rare stall in one step can push a decision past the sum. The headroom absorbs that, along with a retried feature read, a pause in the risk service itself and a retry of a model call that failed instantly. And past 30 ms more waiting buys little: a model that slow is often overloaded or unwell, and the payment's time is better spent on the fallback.
The first version has to learn from somewhere. It is trained on six months of past payment events, which the stream keeps, labelled with the chargebacks that have arrived since. Nothing recorded what the risk service read when each of those payments was decided, so a batch job recomputes every feature from the events: for each past payment, how many merchants the card had used in the 60 seconds before it, and so on.
Three weeks after the model goes live, a bot tests stolen cards at ten merchants in ten seconds, one attempt a second. In the second stage, the risk service's own two-minute count would have declined each card at its fourth attempt; now that rule waits for ten, the lagging merchant count is a model input, and in this story the model scores attempts four to nine at about 0.5 and approves them, until the extreme rule declines the tenth. Each card leaves the burst known to work. Raising the guard to ten left these to the model; why the model missed them is in the training data. The batch job counted from the complete record, so in training every earlier attempt was always there. Live, the velocity job counts an attempt one to two seconds after it happens, so at one attempt a second the merchant count the model is given runs a couple of attempts behind what it learned to expect from exactly this pattern. The model and the stream are both working; the model was trained on numbers it is never given. That is training-serving skew, and Feature stores: online, offline & training-serving skew explains it in depth.
The fix is to stop recomputing. From now on, for every decision, the model writes exactly the feature values it received, its score, its version and the payment's id to Feature history, a store built for scanning months of rows. The write happens after the answer, so it costs the decision nothing. Payments the hard rules decline, and decisions made while the model is unavailable, never reach the model, so they are not in the log. If Feature history is down, the log is buffered and retried; what is lost is a gap in training data, never time from a payment.
The outcomes arrive much later. A fraud chargeback says “this was fraud” weeks after the payment, and a payment nobody disputed is only presumed legitimate once enough time has passed for most disputes to arrive: say 90 days, an assumption. The processor receives chargebacks from the card networks and loads them into Feature history next to the decisions they belong to, by payment id; that feed is outside the drawing. Once a week, a Training Job joins the logged features with the outcomes that have matured, which is the edge labelled training set, and produces the next model version, trained on what the model was actually shown, one-a-second bursts with their lagging counts included. Logged rows need their outcomes before they can teach anything, so the first version trained mostly on logs arrives about three months later. Until then, the four-attempts rule goes back to being a hard rule for payments under US$5, the shape of card testing, which leaves the family's holiday booking alone. Payments the model declined are a gap in that set: a payment that never happened is never disputed, so its outcome stays unknown, and the training job counts it as neither fraud nor legitimate.
The model logs what it was shown; the next model learns from exactly that. Chargebacks also reach Feature history, a feed the drawing leaves out.
Learn moreFeature stores: online, offline & training-serving skewModel serving: inference, versions & safe rolloutFallback
What happens when the model misses its deadline? At 30 ms the risk service stops waiting and decides with the rules and the velocity features, exactly as in the second stage: about 8 ms of work, already done. The payment is never declined because the model did not answer. A decision made without the model is a weaker decision, so the answer says so and the payment service records it that way, and an alert fires when more than 1% of decisions in five minutes are made without it.
“Decide without the model” needs one more choice: what counts as careful for the riskiest payments, such as a large gift card purchase from a new device. Declining them all would turn a model outage into lost sales. Here, those payments are sent back with a request for extra authentication when the merchant supports it, the shopper confirming in the bank's app, a step called step-up authentication; everything else follows the stage-two rules, family holidays caught by the four-merchants rule included. Fallback covers choosing what a fallback does and testing that it works.
If the model is down rather than slow, waiting 30 ms on every payment only to fall back would add 30 ms to every decision for nothing. So the risk service wraps its calls in a circuit breaker: when most calls fail within a few seconds, it stops calling for ten seconds, falls back at once, and then lets a few calls through to see whether the model is back. Circuit Breaker describes the states. If the training job fails, nothing changes in the payment path: the current version keeps scoring, a week older.
A laptop that scored 0.62, and an analyst before capture
A month later, another card from the same kind of breach. One US$1 test payment at 20:31. At 21:40, a US$1,150 laptop from an electronics shop that ships the next morning, ordered from a device the card has not used before, at an hour when this cardholder sometimes shops online, to a delivery address in another city. Some signals say fraud and some do not, and the model scores it 0.62. Below 0.8, so it is approved. The shop ships it at 07:00, and five weeks later the chargeback arrives.
The 0.8 threshold looks like the thing to fix, and moving it is a bad trade either way. Assume about 0.2% of payments, 100,000 a day, land in an uncertain middle, scoring between 0.3 and 0.8, and that about one in ten of them is fraud. Declining that whole band stops about 10,000 fraudulent payments a day and declines about 90,000 good ones, each a lost sale and an annoyed customer, some of whom do not come back. Approving it, as the third stage does, lets the 10,000 through.
The time between authorization and capture opens a third option. The processor has to answer within 100 ms, but the money does not move until the merchant captures, and for a shop that ships the next morning that is hours away. A person cannot look at a payment within 100 ms, but a person can look at it before 07:00.
So the decision now has three outcomes. Below 0.3, approve. At 0.8 or above, decline. In between, approve and review: the payment is approved inside the budget like any other, and the risk service puts it in a Review queue, which feeds an Analyst console where fraud analysts look at it: the card's recent payments, the device, the addresses, the score and the features behind it. An analyst who decides it is fraud voids the authorization from the console, through the payment service, which applies a void or a capture to a payment as one state change: whichever arrives first wins, and if the capture won, the analyst is told that only a refund is left. The merchant hears of the void through its integration and does not ship. Here the clock differs from human review elsewhere, such as content moderation: the payment cannot wait for the analyst. The answer has already gone back to the checkout, and the review happens in the window between authorization and capture.
The analysts cannot see the whole middle, and not every payment in it has a window. The risk service gives each one a priority score, the model's score times the amount, and queues it when that is above 20. The score is not calibrated as a probability, so the figure only ranks payments; it is not a forecast in dollars. Assume the threshold is set so the queue holds about 10,000 payments a day, what the analysts can review. The rest of the middle is approved without review. And for merchants that deliver at once, such as gift card codes and digital downloads, there is no window: a payment in the middle there gets step-up authentication when the merchant supports it, and is approved when it does not.
The final architecture. The analyst's void goes back through the payment service, an arrow left out to keep the drawing readable.
Learn morePriority QueueObservability: metrics, logs & alerting
The queue is not served in arrival order. It is ordered by priority score, and an item's priority rises as its merchant's capture time approaches, so a payment that ships at 07:00 is seen before one that ships in two days; a case is dropped once its payment is captured. Priority Queue covers ordering work by priority, and the endless wait that ordering can leave at the bottom. The laptop's priority score is 0.62 × 1,150, about 713, near the top of the evening's queue. An analyst opens it at 21:52, sees the US$1 test an hour earlier and the delivery address, and voids it. The shop does not ship. The decision went back to the checkout in milliseconds; the person needed twelve minutes, and had nine hours.
The analyst's decision also lands in Feature history as a label, the edge labelled labels: “an analyst judged this payment fraud”, twelve minutes after the payment, instead of a chargeback five weeks later. For a new pattern, the next model version can learn from it after days rather than months. These labels come only from the middle band, so they say little about the payments the model was sure of; the training set still needs the chargebacks for those. The budget does not change at all:
- Decision: still a planned budget of about 38 ms, the same steps as the third stage.
- Putting the payment in the review queue: 0 ms in the budget, because it happens after the answer.
- The review itself: minutes to hours, between authorization and capture, outside the 100 ms.
Analyst capacity, again as assumptions: about two minutes per case, so 10,000 cases a day are about 333 hours of work: about 14 analysts working at any moment, which with breaks means about 17 on each of three eight-hour shifts. Over a day that closes. In the busy evening hours it does not: about 1,440 cases an hour arrive and the 14 at work review about 420. The queue grows in the busy hours and, more slowly, through the rest of the day, when about 480 cases an hour arrive, and drains overnight, when about 140 do; its ordering decides who waits: the highest priority scores with the nearest capture go first, and the cases at the bottom may reach their capture time unreviewed, in which case they are captured exactly as they would have been in the third stage.
What happens when the review queue is down? Payments in the middle are still approved, because the decision never depended on the queue. The risk service keeps the items it could not queue in a small local buffer and retries; an item lost there, when an instance dies with it, is a payment approved without review, which is the third stage's behaviour, and a check against the payment service's record of decisions finds and counts it. The queue hands each case to one analyst at a time and takes it back if that analyst's console goes quiet, so a closed laptop does not strand a case; Message queues & async workers covers that hand-off.
And when the queue suddenly fills? A spike in queued payments, say three times the usual for that hour, usually means one of two things: a card-testing attack on a group of merchants, or a model version that has started scoring ordinary payments as uncertain. Either way someone has to look now, so the spike pages the on-call fraud lead, together with the share of decisions made without the model, the velocity job's lag and the count of unscored payments. Observability: metrics, logs & alerting covers turning those numbers into alerts.
Where the 100 milliseconds go
- Hard rules: about 3 ms. The Tuesday card spends US$2,348.49 in ten approved payments.
- Velocity windows: about 8 ms. The Tuesday card is declined at its fourth merchant, after US$4.50; with 50 seconds of stream lag and no defence, all ten would pass, which is why the risk service keeps its own two-minute count. A family booking a holiday is declined too.
- A model with a 30 ms deadline: a planned 38 ms, about 8 ms while the circuit breaker skips a model that is down. The slower thief's gift card is declined, the family's booking approved, and a late or absent model falls back to the second stage's rules, never to a blanket decline.
- Approve now, review before capture: still a planned 38 ms. The 0.62 laptop is approved within the budget and voided by an analyst nine hours before it would have shipped.
Under half the budget is ever spent on purpose. The rest is what keeps even a bad evening's slowest decisions inside the 100 ms timeout, and the design never trades it for a slower model. The fraud check's job is to be right as often as it can within its share of the shopper's wait; its other job, just as important, is to get out of the way when any of its parts is late.
Every box, and the failure that brought it
- Merchant checkout: waits for the answer; sends what it knows about the order, such as the delivery address and when it will capture.
- Payment service: asks for a decision with a 100 ms timeout, forwards unscored when there is none, and publishes every payment and its outcome to the stream.
- Card network: carries the authorization to the issuing bank, which makes its own decision.
- Risk service: hard rules first, features and model next, approve, decline or approve and review; never waits past its own deadlines. It came from ten approved payments that each looked fine alone.
- Payment events: every payment and attempt, declines included, for whatever needs to count them. It came from counting that had to move off the decision path.
- Velocity windows: counts and sums per card, device, IP and merchant over sliding windows, each payment counted once. It came from the sequence no single payment shows.
- Online features: the current value of every feature, read in one round trip, plus the risk service's own two-minute set per card. It came from a database that could not count fast enough inside 100 ms.
- Fraud model: a score from dozens of features, inside 30 ms or not at all; it logs exactly what it was shown. It came from a thief who learned the rules' thresholds.
- Feature history: what the model saw, what it said, and what turned out to be true, from chargebacks and from analysts. It came from a bot burst the first model under-scored because it had learned from recomputed counts.
- Training Job: once a week, the next model from matured outcomes. It came from a model that must learn from what it was shown, not from a recomputation.
- Review queue: the uncertain middle, ordered by priority score and capture time. It came from a threshold that forced one mistake or the other.
- Analyst console: where a person voids an authorization before capture, and where the fastest labels come from. It came from the hours between authorization and capture.
Fraud work this drawing leaves to others
- The charge itself. Capturing, settling, refunds and reconciliation belong to the payment system, not to the decision before it.
- 3-D Secure in depth. The usual form of step-up authentication for online card payments has its own flows, liability rules and effect on how many shoppers finish paying; here it is one option among the decision's outcomes.
- Fraud rings as graphs. Linking cards, devices, addresses and accounts that share something, to catch a ring rather than a card, is a design of its own, usually beside this one.
- Device fingerprinting. Recognising “the same laptop” across payments is assumed here, not built.
- Explaining a decline. Merchants, regulators and sometimes cardholders can ask why a payment was declined; rules answer in one sentence, a model needs more work, and the requirements vary by country.
- Disputes. What happens after a chargeback, evidence and appeals included, is the card networks' process, not the fraud check's.
Build it yourself
The Real-Time Fraud Detection Challenge asks for this system, requirement by requirement: an approve, decline or review decision for every transaction within 100 ms, velocity features over sliding windows from the transaction stream, hard rules combined with a model score, online features consistent with the ones used in training, suspicious transactions queued to an analyst case console with alerts for spikes, analyst outcomes stored as labels, and bursts absorbed without adding decision latency.
Its palette names some of the boxes differently:
- Payment events: Kafka. Velocity windows: Apache Flink.
- Online features: Redis or the Feature Store; the Feature Store can also hold the history a training set is built from.
- Payment service and Risk service: REST API boxes. Analyst console: a web app, with PostgreSQL behind it for cases and their outcomes.
- Spike alerts: PagerDuty, fed by whatever watches the queue.
- What the palette leaves out: there is no box for the card network, no message queue for the review queue (a Kafka topic or a PostgreSQL table can play it) and no training job, so note on your Grid where training happens and what it reads.
Then put the Tuesday card through your drawing: write on the edge into the risk service how many milliseconds each step may take, on the model's edge what happens at its deadline, and next to the velocity job how far behind it may fall before the rules tighten. The ML Serving & Feature Store Challenge takes the third stage further on the serving side, with a model registry, live traffic split between two versions and drift monitoring against the training data, which this post names and leaves for that Challenge.