Bird
0
0

You need to design a balance calculation system that handles millions of transactions per day with real-time updates. Which design choice best supports scalability and accuracy?

hard📝 Trade-off Q15 of 15
LLD - Design — Splitwise (Expense Sharing)
You need to design a balance calculation system that handles millions of transactions per day with real-time updates. Which design choice best supports scalability and accuracy?
AIgnore debits and only add credits to simplify calculation
BUse a single database transaction to update balance after each transaction
CStore all transactions in memory and recalculate balance on every request
DBatch transactions and update balance periodically with distributed processing
Step-by-Step Solution
Solution:
  1. Step 1: Consider scalability needs

    Millions of transactions require efficient processing; single updates per transaction cause bottlenecks.
  2. Step 2: Evaluate batch processing benefits

    Batching with distributed processing reduces load and maintains accuracy by processing groups of transactions.
  3. Step 3: Reject other options

    Single DB transactions cause slowdowns, in-memory recalculation is memory-heavy and slow, ignoring debits causes incorrect balances.
  4. Final Answer:

    Batch transactions and update balance periodically with distributed processing -> Option D
  5. Quick Check:

    Batch + distributed processing = scalable & accurate [OK]
Quick Trick: Batch and distribute processing for large-scale balance updates [OK]
Common Mistakes:
  • Updating balance per transaction causing bottlenecks
  • Recalculating balance on every request wasting memory
  • Ignoring debits leading to wrong balances

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes