Problem statement
Design the service that enforces spending and transfer limits on every transaction in real time. Before a payment is authorized, the service checks it against a stack of limits — per-transaction caps, rolling daily and monthly velocity limits, per-merchant-category ceilings — and returns allow or deny in milliseconds. The core tension is correctness under concurrency: two transactions racing on the same account must not both slip past a limit that only one should pass.
Operating context. This sits on the synchronous authorization hot path, so latency is unforgiving. Limits are consumed on authorization and must be released or settled later, and windows roll continuously (a trailing 24 hours, a calendar month). Limit policies vary by account tier and can be updated by risk operators. Assume 30000 authorization checks/sec at peak, tens of millions of accounts, and a hard rule that an account can never exceed a limit even under simultaneous requests.
Out of scope. The payment authorization decision itself beyond the limit verdict, fraud-model scoring, the ledger and settlement, and the risk-operator console beyond consuming its policy updates. Assume separate teams own authorization, fraud, ledger, and the policy tool.
What to produce. A high-level architecture covering: the low-latency check-and-consume path, the data model for limits and rolling-window counters, guaranteeing no over-limit under concurrent transactions on one account, reserve-then-settle/release semantics for pending authorizations, rolling-window accounting, propagating policy changes quickly, and scaling to tens of thousands of checks per second. Sketch the components and request flow; we will probe specifics in checkpoints.
Functional requirements
- Evaluate a proposed transaction against per-transaction, rolling-daily, rolling-monthly, and category limits and return allow or deny.
- Atomically consume limit budget on approval so concurrent transactions on one account cannot jointly exceed a limit.
- Reserve budget for a pending authorization and later settle the final amount or release the hold on expiry/reversal.
- Maintain rolling-window counters that continuously expire spend older than the window boundary.
- Apply risk-operator policy updates (new limits/tiers) to subsequent checks within seconds.
Non-functional requirements
- Serve 30000 limit checks/sec at peak across tens of millions of accounts.
- Check-and-consume p99 < 20 ms on the synchronous authorization path.
- 99.99% availability; a limit-service failure must fail safe per an explicit allow/deny default policy.
- Strict correctness: no account ever exceeds a configured limit, even under concurrent requests or retries.
- Rolling-window counters accurate to the second with bounded memory per account.
- Policy changes propagate to all check nodes within 5 seconds.
Topics
- System Design HLD
- Fintech Limits
- Data Consistency
- Concurrency Control
- Scaling Low-Latency