Problem statement
Design the engine that accrues interest on tens of millions of savings and loan accounts every day. For each account it computes the day's interest from the applicable rate and balance, records the accrual, and periodically capitalizes accrued interest into the balance by posting to the ledger. Because interest touches every customer's money, the arithmetic must be exact, rounding must be consistent, and an account must never be accrued twice for the same day.
Operating context. Rates vary by product and tier and can change mid-period, sometimes retroactively. Balances change throughout the day from transactions. The engine runs a daily accrual cycle across all accounts and a capitalization/posting cycle on each account's schedule. Assume 60 million accounts, exact decimal money math with a defined rounding policy, and a hard rule that accruals for a given day are computed exactly once per account.
Out of scope. The rate-setting/product-configuration system, tax withholding, the ledger's internal correctness, and the customer-facing display of accrued interest. Assume separate teams own product config, tax, and the app.
What to produce. A high-level architecture covering: how the daily accrual cycle is triggered and parallelized, how you obtain the correct rate and the day's balance for each account, exact-once daily accrual under retries, handling mid-period and retroactive rate changes (recompute/backdated adjustments), the capitalization step that posts to the ledger, exact decimal arithmetic and rounding, and meeting the daily window at 60M accounts. Sketch the stages and dataflow; we will probe specifics in checkpoints.
Functional requirements
- Compute each account's daily interest from its applicable rate, tier, and accrual basis, recording an accrual entry.
- Guarantee that a given account is accrued exactly once for each calendar day, even under retries.
- Handle mid-period and retroactive rate changes by recomputing and posting backdated accrual adjustments.
- Capitalize accrued interest on the account's schedule by posting a balanced entry to the ledger.
- Expose the accrued-but-not-yet-capitalized balance for any account on demand.
Non-functional requirements
- Accrue 60 million accounts per day and finish the daily cycle within a 3-hour window.
- Accrual throughput of at least 10000 accounts/sec, horizontally scalable.
- Money math is exact decimal with a fixed rounding policy; total rounding error per day bounded to zero net across the book.
- 99.95% of accounts accrued within the daily SLA; no account double-accrued for any day.
- Retain per-day accrual detail for 7 years, tens of billions of rows, queryable per account.
- A retroactive rate correction is applied deterministically and is fully auditable against the original accrual.
Topics
- System Design HLD
- Fintech Interest
- Data Batch
- Data Consistency
- Patterns Idempotency