In a ledger system, the balance of an account is calculated by summing all credits and debits. Which of the following best describes the correct approach to calculate the balance?
Think about how credits and debits affect the account balance.
Credits increase the balance, debits decrease it. So, summing credits and subtracting debits gives the correct balance.
You need to design a service that calculates user balances in real-time for millions of users. Which architectural choice best supports scalability and low latency?
Consider how to reduce computation and improve response time.
Precomputing balances and caching reduces load and latency, making the system scalable.
In a system where multiple transactions update the same account balance concurrently, what is the best approach to ensure balance consistency?
Think about how to detect and handle conflicting updates efficiently.
Optimistic concurrency control allows concurrent updates but checks versions to avoid conflicts, ensuring consistency without heavy locking.
Choosing between real-time and batch processing for balance calculation involves tradeoffs. Which statement correctly describes a key tradeoff?
Consider latency, complexity, and resource consumption.
Real-time systems provide quick updates but need more resources and complex design; batch systems are simpler but have latency.
You expect 10 million users, each with 1000 transactions per year. Each transaction record is 200 bytes. Estimate the total storage needed for 3 years of transaction history.
Calculate total transactions and multiply by record size, then convert to terabytes.
Total transactions = 10M users * 1000 transactions/year * 3 years = 30 billion transactions.
Storage = 30B * 200 bytes = 6 trillion bytes = 6 terabytes.