โ† Back to list

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?

Anuragkumbhare ยท 2026-01-10 04:46 ยท 0 claps ยท 2.3 min read
#design-systems #distributed-systems #concurrency-control #scalable-architecture #redis
Open on Medium โ†—
Wiki topics: PRD ยท Product Design ๐ŸŽฌ ยท Film & Television ๐Ÿ›๏ธ ยท Architecture

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:

  1. Temporary seat lock
  2. 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:

  1. Validate lock ownership
  2. Write booking to transactional DB
  3. Mark seats as permanently booked
  4. 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