← Bank of America Interview Insights
Said Redis distributed lock and DB-level constraints.
Start by clarifying the requirements and constraints, then propose a solution that ensures data consistency and handles concurrency, such as using database transactions with locking or optimistic concurrency control. Discuss trade-offs between different approaches and how you would scale the solution.
Pro tip: Mention that in a banking context, correctness and auditability are paramount, so you'd lean towards pessimistic locking or serializable isolation to prevent double-booking, even at some cost to throughput.
Ask about expected load, consistency requirements, and whether the system is distributed. This shows you don't jump to solutions without understanding the problem.
Explain that the main issue is a race condition where multiple users read the same seat as available and then try to book it, leading to double-booking.
Suggest using database transactions with appropriate isolation levels (e.g., serializable) or locking mechanisms (pessimistic or optimistic) to ensure only one booking succeeds.
Compare approaches: pessimistic locking ensures consistency but may reduce concurrency; optimistic locking improves throughput but requires retry logic. Choose based on business needs.
Mention how to scale (e.g., sharding by event or seat) and handle failures (e.g., idempotent operations, distributed locks if needed).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.