System Design: IRCTC Train Booking (Walnut Rail: Tatkal Rush, Seat Inventory, Waiting Room, Bot Defense, Auto Refunds)
Goal: Design a train booking system like IRCTC. IRCTC is India's website and app for booking train tickets. Our design is called Walnut Rail.
Every morning at 10:00, the AC Tatkal quota opens for the trains of the next day. A quota is a set of berths kept for one group of travelers. Tatkal is the quota kept for people who book late. We plan for about 2 million bookings, filled in ahead of time, to arrive in that one second. Many bots arrive in the same second too.
The PRS is the railways' system that keeps all berth bookings. The railways are building a new PRS for 2,500 tickets a second and 66,700 enquiries a second. An enquiry is a question that changes nothing, such as "how many berths are left?". We use these public targets as our own design capacity.
1. What We Are Building
🔒 Premium section
2. Requirements and Scale
2.1 What the System Must Do
An opening window is a sale that opens at a fixed time of day. AC Tatkal opens at 10:00, and non-AC Tatkal opens at 11:00. At 08:00 each day, the date 60 days ahead opens for booking. Many festival travelers try to book at that moment.
These are the features Walnut Rail must have. FR stands for functional requirement. A functional requirement is a thing the system must do.
| ID | Requirement |
|---|---|
| FR1 | Sign up, link Aadhaar, and save a list of passengers to book for. |
| FR2 | Search trains and see how many berths are left, by class and quota. |
| FR3 | Book the general quota up to 60 days ahead and Tatkal one day ahead, under the railway rules. |
| FR4 | Prepare a booking for an opening window, such as Tatkal or the 08:00 opening. Verify it before the opening. Then get a fair place in line. |
| FR5 | Get a result: CNF, RAC, WL, or "Closed", which means nothing is left. |
| FR6 | Pay by UPI on the phone, card, net banking or wallet. Then get the ticket, or get the money back. |
| FR7 | Cancel and get the refund the rules allow. Then let RAC and WL passengers move up into the freed berths. |
| FR8 | Prepare charts, the final berth lists. A chart is made 10 hours before departure. For morning trains, it is made at 20:00 on the day before. Charts are made again 30 minutes before departure. |
| FR9 | Let station counters and travel agents book under the same rules as the App. |
| FR10 | Show PNR status, which is the state of a ticket. Send SMS or app messages. |
FR2 and FR10 only read data. They make up most of the traffic. Only FR3 to FR7 change berths.
FR4 and FR5 are hard because everyone arrives in the same second, at the start of an opening window. FR6 is hard for a different reason. A bank can answer after the berth has already gone to someone else. Even then, the money must end as a ticket or a refund.
2.2 How Well It Must Do It
p50 is the median time. Half of all requests finish faster than the p50 time. p99 is the time within which 99 out of every 100 requests finish. So p99 tells us about the slowest requests.
A zone is a group of data center buildings with its own power and network. A region is a group of zones in one city area. Availability is the percent of a month in which a service works.
An NFR is a non-functional requirement. It says how well the system must do its work, not what work it does. Three words from the booking flow appear in the table. They are explained in full later, with the API. A draft is a booking prepared before an opening window, as in FR4. A hold keeps berths for one draft for a few minutes while the person pays. An owner is the one worker that may change the seats of one train on one date.
| ID | Requirement | Target |
|---|---|---|
| NFR1 | Capacity | 2,500 tickets a second and 66,700 enquiries a second at design capacity. At 10:00:00, 3 million requests a second at the edge |
| NFR2 | No double sale | Once a stretch of a berth is saved as sold, it belongs to one passenger at a time. This holds even when a server crashes or another server takes over. |
| NFR3 | Confirmed tickets | A ticket shown as confirmed survives the loss of a zone or of a whole region. This is because the other region has a copy before the person is told. There is one exception. Say the link to the other region was already down for more than 2 s when a region is lost. Then some confirmed tickets can be lost too. The Reconciler checks every payment against its booking. It gives each of these people the same berth, another berth or a refund within 1 hour. |
| NFR4 | Fair order | Berths kept for one quota are given in the order of the 10:00 line. Network delays can make a request reach its train's owner up to 20 ms late. Such a request loses at most about 8 places in its pool. A request retried after a crash loses its place. |
| NFR5 | Latency | Seat availability answers within 300 ms at p99. A hold result comes within 1 s at p99 after the draft is let in. A confirmation comes within 2 s at p99 after the bank's payment result |
| NFR6 | Freshness | The seat counts people see are at most 2 s old at p99. Under overload, while we turn away less important work, they may be up to 10 s old |
| NFR7 | Money | Every captured payment ends as a ticket, or as a refund started within 1 hour. A captured payment is money the bank has already taken |
| NFR8 | Availability | The booking path works 99.95% of each month. In every opening window, 99.9% of the drafts let in get a hold result within 1 s. No planned work happens from 07:30 to 12:30 |
| NFR9 | Zone loss | No confirmed data is lost. Owners move to another zone within 5 s |
| NFR10 | Rules | The Policy engine is the service that holds the railway rules. It enforces every Tatkal rule. The Inventory engine, which keeps the berths, checks the rules again |
Where the targets come from:
NFR2 to NFR10 are our choices. IRCTC publishes no target for latency, the time a request takes. It also publishes no target for how fresh its seat counts are.
- NFR8. The 08:00, 10:00 and 11:00 openings all fall inside the quiet hours, from 07:30 to 12:30. So no change goes live during any opening. We also set a target for each window, not only for the month. A monthly figure alone could hide 20 minutes lost at 10:00.
- NFR10. The rules themselves are public railway rules. Checking them twice, in two separate services, is our choice.
2.3 The Numbers
The numbers below decide how big each part of Walnut Rail must be. Later, in the capacity plan, we turn them into servers. Three terms about load come up many times:
- Daily average. A year of tickets spread evenly over every second of the year.
- Design capacity. The load we can handle without stopping during the morning windows, in tickets and in enquiries.
- Record minute. The most tickets IRCTC has ever sold in one minute.
The most important point comes first. The busy moment is short. So we size the system for the 10:00 second, not for the whole day.
In 2025, AC Tatkal sold 62.5% of its online tickets in the first 10 minutes after opening. That is 5 out of every 8 tickets. Its busiest minute was the second minute. So a system sized for the daily average would fail at 10:00:01. The table shows how big the gap is. Design capacity is about 120 times the daily average.
In the table, "Real" means a public figure reported by the government, Parliament or the news. Its source is listed at the end. "Ours" means our plan, choice or assumption. "Sum" means we worked it out from the numbers above it.
| What | Number | How we got it | Real or ours | What it sizes |
|---|---|---|---|---|
| Tickets a day, all channels | about 1.78 million | 650.8 million reserved tickets from Jun 2025 to Jun 2026, reported by the government press office in 2026, ÷ 365 | Real | The size of the ticket records |
| Daily average | about 21 tickets a second | 1.78 million ÷ 86,400 seconds in a day | Sum | A normal second |
| Design capacity, tickets | 2,500 a second | The new PRS target of 150,000 tickets a minute, which we adopt: 150,000 ÷ 60 | Real target, adopted | The speed of booking at 10:00 |
| Design capacity ÷ daily average | about 120 times | 2,500 ÷ 21 | Sum | The gap between the opening and a normal second |
| Design capacity ÷ record minute | about 4 times | 150,000 ÷ 37,410. The record minute was on 16 Aug 2025, reported in the news in 2026 | Sum | Room above the record |
| Design capacity, enquiries | about 66,700 a second | The new PRS target of 4 million enquiries a minute, which we adopt: 4 million ÷ 60 | Real target, adopted | The read path |
| Read-to-write ratio | about 27 | 66,700 ÷ 2,500 | Sum | Why enquiries must stay away from the berths |
| Open train runs | about 143,000 | 2,300 × 62. Trains: a 2025 answer in Parliament gave 2,238 long-distance Mail and Express trains a day, and we round this up to 2,300. Days: the 60 days of advance booking, the journey day, and runs that are between their charts | Real, rounded | The memory for all seats |
| Berths per train run | 700 on average, 2,000 at most | 1.514 million berths a day, from a news report with no date, ÷ 2,238 ≈ 680, so we plan for 700. Long trains have about 2,000 | Real, rounded | The work for one train |
| Tatkal crowd at 10:00 | 2 million drafts | Our plan for a busy day. The Ministry of Railways reported 8.26 million logins a day on average in 2024-25 | Ours | The 10:00 line and the OTP checks |
| Edge requests in the 10:00 second | 3 million a second | Our assumption. A 2026 answer in Parliament said IRCTC received 24.04 billion requests in October 2025. 24.04 billion ÷ 31 days ÷ 86,400 seconds ≈ 9,000 a second on average. The opening is hundreds of times that | Ours, from a real average | The edge servers and the bot checks |
| Busiest AC Tatkal minute, 2025 | about 380 tickets a second | 22,827 tickets in the second minute, reported in the news in 2025, ÷ 60. This is far below 2,500 | Real | A check that 2,500 is enough |
| Inventory memory | about 29 GB per copy | 143,000 open runs × about 200 KB per run, our estimate | Ours | The inventory servers |
| Count snapshots, small summaries of the seat counts of each run | about 700 MB | 143,000 open runs × about 5 KB of seat counts per run, our estimate | Ours | The seat-count cache, with a full copy on every node |
The edge sees a much larger number. About 3 million requests a second arrive at 10:00, but at most 2,500 tickets a second are sold. Most of this gap is bots, repeated clicks and status checks. This is why the design puts cheap gates in front of the berths. The gates must handle millions of requests a second, so that the berths see only thousands.
2.4 Out of Scope
We leave out unreserved tickets and suburban trains. We also leave out meals, hotels and tour packages, which are sold on the same website. Train running status is out too. A connecting journey or a round trip is treated as separate bookings.
We also leave out the fare engine, which works out prices. Fares appear only as the amounts people pay, and this includes the rising fares of Premium Tatkal. Refund law appears only as the rules the design follows when a ticket is canceled or a payment fails.
Station counters are in scope only as one more channel, which means one more way to book. Their bookings pass through the same rules as the App.
3. The API and the Core Data
🔒 Premium section
4. High-Level Design
🔒 Premium section
5. Deep Dive: Edge and Traffic Security
🔒 Premium section
6. Deep Dive: Who May Book
🔒 Premium section
7. Deep Dive: The Virtual Waiting Room at 10:00
🔒 Premium section
8. Deep Dive: Availability Reads and Enquiries
🔒 Premium section
9. Deep Dive: The Seat Inventory Data Model
🔒 Premium section
10. Deep Dive: The Inventory Store, Partitions and Failover
🔒 Premium section
11. Deep Dive: Booking and Payment
🔒 Premium section
12. Deep Dive: Cancellation, Waitlist Movement and Chart Preparation
🔒 Premium section
13. The Tatkal Funnel: Layered Load Shedding
🔒 Premium section
14. Capacity, Cost and Rehearsing 10:00
🔒 Premium section
15. What Happens When Each Part Goes Down
🔒 Premium section
16. Moving Off the Legacy PRS
🔒 Premium section
17. Bottlenecks
🔒 Premium section
18. Multi-Region
🔒 Premium section
19. Trade-Offs We Chose and Rejected
🔒 Premium section
20. What IRCTC Has Said in Public, and What Walnut Rail Does
🔒 Premium section
21. In the Interview (45 and 60 Minutes)
🔒 Premium section
22. What to Remember
🔒 Premium section
23. Further Reading
🔒 Premium section
Explore the Technologies
🔒 Premium section