How Does BookMyShow Ensure Two People Donโt Book the Same Seat at the Same Time? ๐๏ธ
Ever tried booking movie tickets during a blockbuster release?
How Does BookMyShow Ensure Two People Donโt Book the Same Seat at the Same Time? ๐๏ธ
Ever tried booking movie tickets during a blockbuster release?
You select the seats. You hesitate for a second. And suddenly โ โSeat no longer available.โ
That message is the visible tip of a very hard distributed systems problem:
How do you ensure millions of users donโt book the same seat at the same time?
Letโs break down how platforms like BookMyShow solve this.
The Core Problem
Design a system that:
- Allows real-time seat selection
- Prevents double booking
- Handles massive concurrency
- Keeps UX fast and intuitive
- Recovers cleanly from failures
This is not just a database problem โ itโs a coordination problem.
Naive Approach (Why It Fails)
SELECT seat WHERE available = true
UPDATE seat SET available = false
โ Two users can read available = true simultaneously
โ Both attempt to book
โ One overwrites the other
This race condition explodes at scale.
Key Insight
Seat selection โ Seat booking
Modern ticketing systems break this into two phases:
- Temporary seat lock
- Final booking confirmation
This separation is critical.
High-Level Architecture
Client
โ
โผ
API Gateway
โ
โผ
Seat Availability Service
โ
โโโ Seat Lock Store (Redis)
โโโ Booking DB (SQL)
Phase 1: Seat Locking (The Real Battle)
When you select a seat, it is not booked โ it is locked.
What Happens Internally
User A selects Seat S1
System:
- Creates a temporary lock
- Lock has:
- Seat ID
- User ID
- Expiry time (e.g. 5โ10 minutes)
Why Redis?
Redis is used because:
- Extremely fast (in-memory)
- Atomic operations
- TTL support (auto-expiry)
Atomic Seat Locking
Redis supports atomic commands like:
SET seat:S1 userA NX EX 600
Meaning:
- Set only if not already locked
- Auto-expire after 10 minutes
Result:
- First user wins
- The second user instantly fails
No race conditions. No double booking.
Phase 2: Payment Window
Once seats are locked:
- User proceeds to payment
- Seats are invisible to others
- Lock countdown shown in UI โณ
If payment succeeds โ finalise booking If payment fails / times out โ lock expires โ seats return to pool
Phase 3: Final Booking (Strong Consistency)
On successful payment:
- Validate lock ownership
- Write booking to transactional DB
- Mark seats as permanently booked
- Remove Redis lock
SQL transaction ensures:
- Exactly-once booking
- No partial state
Why Not Lock Directly in the Database?
Database locks:
- Are slow
- Donโt scale under heavy load
- Can cause cascading failures
Redis locks:
- Are lightweight
- Auto-expire
- Isolate failure
Databases are for truth. Redis is for coordination.
Handling Edge Cases
๐ฅ User Closes App
โ Redis TTL expires โ Seats auto-released
๐ฅ Payment Succeeds, Confirmation Fails
โ Booking service checks DB โ Idempotent booking logic โ User gets ticket
๐ฅ Multiple Seats Selected
โ Lock all seats atomically โ Either all locked or none
Real-Time Seat Map Updates
Seat maps are powered by:
- Cached availability
- WebSockets / polling
- Event-driven updates
When a seat is locked:
- Other users see it turn grey instantly
Scaling for Blockbuster Releases
BookMyShow scales by:
- Partitioning shows by movie + theatre
- Sharding Redis by show ID
- Rate-limiting seat selection
- Pre-warming caches before releases
No global locks. Everything is scoped.
Why This Works
โ No global synchronization โ Fast failure detection โ Auto-recovery via TTL โ Clear separation of concerns
This pattern is used by:
- Airlines
- Railways
- Concert ticketing platforms
- Sports events
Final Takeaway
Preventing double booking isnโt about stronger locks โ Itโs about smarter coordination.
Lock fast. Expire aggressively. Commit only once.
Thatโs how platforms like BookMyShow survive peak traffic without chaos.
๋ฉํ๋ฐ์ดํฐ
- post_id
- e8a3c452c6cd
- slug
- how-does-bookmyshow-ensure-two-people-dont-book-the-same-seat-at-the-same-time-๏ธ-e8a3c452c6cd
- url
- https://medium.com/@anuragkumbhare2043/how-does-bookmyshow-ensure-two-people-dont-book-the-same-seat-at-the-same-time-%EF%B8%8F-e8a3c452c6cd
- canonical_url
- https://medium.com/@anuragkumbhare2043/how-does-bookmyshow-ensure-two-people-dont-book-the-same-seat-at-the-same-time-%EF%B8%8F-e8a3c452c6cd
- author_url
- https://medium.com/@anuragkumbhare2043
- status
- ok
- fetched_at
- 2026-06-24 16:30:55