[00:03]
tickets. That's what happened when Coldplay tickets went live in India. Now picture this. Two people tap the same seat at the exact [music] same second. Who gets it? This is a classic system design interview question. How would you
[00:17]
build a ticket booking system where one seat is never sold twice? The first thought is simple. Check the database. Is seat A12 free? Yes, book it. But here's where it breaks. Person A checks and it's free. Person B checks at the
[00:33]
same moment and it's free for them too. Both book it. Two tickets, one seat, and [music] a big fight at the stadium gate. So, here's how you'd really build it. Step one, don't let everyone in at once. [music] 1.3 crore people opening the
[00:47]
booking page together will crash anything. So, send them to a virtual waiting room. Everyone gets a number and the system lets people in small batches. [music] That's the six lakh people ahead of you screen. Step two, show the seat
[01:01]
map from fast memory like Reddus. Millions of people just looking at seats should never [music] touch the main database. Step three, the moment you tap a seat, the system holds it for you. And here's the key. Checking and holding
[01:15]
happen in one [music] single step. Give me the seat, but only if nobody has it. If two people try in the same millisecond, [music] only one wins. the other sees seat not available right away. [music] But here's the trap. You
[01:29]
held the seat then went looking for your card or your payment failed or you just closed the app. Now that seat [music] is stuck with you forever. So every hold stuck with you forever. So every hold gets a timer say [music] 10 minutes. No
[01:43]
payment by then the seat goes back to everyone automatically. Second trap. Your payment goes through but your network drops. You panic and tap pay again. Do you get charged twice? No, every booking carries a unique ID. If
[01:57]
the same ID comes in twice, the system knows it's a repeat and ignores it. Step four, only after the payment succeeds is the seat marked sold in the main database permanently. Step five, bots. One script can grab hundreds of seats in
[02:11]
seconds. So, you cap tickets per person. Coldplay tickets were capped at four per user, and you block [music] anyone sending too many requests. One last thing, every show is its own little world. So split the data across servers
[02:25]
by show. A Coldplay rush in Mumbai won't slow down someone booking a movie in Chennai. And that's how one system handles crows of fans without selling a handles crows of fans without selling a single seat twice.