Main
Interview Coaching
Learn
System Design
ML System Design
DSA
Behavioral
Interview Insights
Get Premium
Patterns
Dealing with Contention
Learn about how to deal with high contention in your system design interview.
The Problem
Consider buying concert tickets online. There's 1 seat left for The Weeknd concert. Alice and Bob both want this last seat and click "Buy Now" at exactly the same moment. Without proper coordination, here's what happens:
- Alice's request reads: "1 seat available"
- Bob's request reads: "1 seat available" (both reads happen before either write)
- Alice's request checks if 1 ≥ 1 (yes, there is a seat available), proceeds to payment
- Bob's request checks if 1 ≥ 1 (yes, there is a seat available), proceeds to payment
- Alice gets charged $500, seat count decremented to 0
- Bob gets charged $500, seat count decremented to -1
Both Alice and Bob receive confirmation emails with the exact same seat number. They both show up to the concert thinking they own Row 5, Seat 12. One of them is getting kicked out, and the venue has to issue a refund while dealing with two very angry customers.
Race Condition Timeline
The Solution
Single Node Solutions
Atomicity
Pessimistic Locking
Isolation Levels
Optimistic Concurrency Control
Multiple Nodes
Two-Phase Commit (2PC)
Distributed Locks
Saga Pattern
Choosing the Right Approach
When to Use in Interviews
Recognition Signals
Common Interview Scenarios
When NOT to overcomplicate
Common Deep Dives
"How do you prevent deadlocks with pessimistic locking?"
"What if your coordinator service crashes during a distributed transaction?"
"How do you handle the ABA problem with optimistic concurrency?"
"What about performance when everyone wants the same resource?"
Conclusion

Schedule a mock interview
Meet with a FAANG senior+ engineer or manager and learn exactly what it takes to get the job.