News · New this week

Tatkal booking system design: waiting room, rate limit, seat lock

A typical system design answer for the 10 AM Tatkal rush, turning lakhs of simultaneous clicks into one orderly line.

The interview question sounds simple. Tatkal opens at 10 AM, lakhs of people press Book in the same second, so how do you handle it? The answer has three parts. You need a waiting room, a rate limit on the booking API, and a seat lock that times out.

One caveat first. IRCTC's exact design isn't public. What follows is the typical way to build this, not a description of their internals.

The shape of the rush

AC Tatkal opens at 10 AM and non-AC at 11 AM. Most of the seats go in the first few minutes. So the load isn't spread out. Lakhs of users arrive at 10:00:00, all at once, and then it's over quickly.

If you send all of them straight to the database, the server goes down. That's the problem to solve, and the rest of the design follows from it.

Waiting room, then a rate limit

The first piece is a waiting room. It's a line. Every user gets a number, and users are let in at a fixed speed instead of all together.

Behind it sits the booking API, which runs at a limit. Only as many people go in as the system can handle. That's rate limiting, which means holding traffic to a safe speed so the system keeps running.

The two work as a pair. The waiting room decides who goes next. The rate limit decides how fast. Together they stop the crowd from reaching the database in one wave.

Seat lock with a timeout

Once someone gets a seat, it's locked for a few minutes so nobody else can take it. The user then goes to payment.

Two outcomes are possible there. If payment goes through, the seat is confirmed. If the timeout runs out first, the seat goes back into the pool.

The timeout matters because a lock with no expiry would let abandoned payments hold seats forever.

Why double booking doesn't happen

There's one lock per seat. A database transaction makes sure two people can't end up with the same seat. If someone asks how you prevent double booking, say it plainly. One seat gets one lock, and the database enforces it.

What to take from it

When you answer this in an interview, walk through the chain in order. Start with the waiting room, then the rate limit, then the seat lock with timeout, and finish with payment either confirming or releasing the seat. The one line to remember is to turn the rush into a line. Practise saying it out loud.

  • #systemdesign
  • #irctc
  • #tatkal
  • #hinglish

More reels

All news →