The short answer: Distributed Locking with Redis.
When you select a seat, the system creates a temporary, time-limited lock in a high-speed cache (Redis) using the SET ... NX command.
This ensures that even if two users click at the exact same millisecond, the single-threaded nature of Redis guarantees only one request succeeds. The "loser" receives an immediate error without overloading the main database.
Interactive simulation of two users racing for the same seat.
IMAX 3D • Today, 7:00 PM
SCREEN THIS WAY
| seat_id | status | user |
|---|---|---|
| A1 | AVAILABLE | NULL |
IMAX 3D • Today, 7:00 PM
SCREEN THIS WAY
Checking a traditional SQL database for seat availability every time a user taps a seat is too slow for millions of users. Redis is an In-Memory store, meaning it reads/writes in microseconds.
BookMyShow uses Redis for the "Selection Phase" to handle the high throughput. The main SQL database is only hit when the payment is actually confirmed.
The core mechanism preventing double booking is the atomic Redis command:
"I lock this seat so no one else can touch it while I decide."
Great for user experience (no disappointment at checkout), but can leave seats empty if users abandon carts.
"I'll let everyone try to book, and check for conflicts only at the final payment step."
Better for system performance, but frustrating for users ("Sorry, seat taken" errors at payment).