Live demo · tatkal train booking

Lakhs of people, one berth each.
Never the same berth twice.

MiddleBerth is a backend built as five Spring Boot microservices around Kafka, PostgreSQL and Redis. Book a real berth below, pay with a Razorpay test card, and watch every call it makes.

1

Your account

A real account. The password is hashed with BCrypt, and five wrong tries lock it for fifteen minutes.

2

Pick a train

Tatkal opens one day ahead. These counts come from search-service, which reads Redis and never touches the booking database.

3

Book and pay

Choose a train and class above.

How a booking works

  1. nginxHTTPS, the only way in
  2. gatewaychecks the JWT, limits each user
  3. booking-servicechecks at the door, replies 202
  4. Kafka15 partitions, keyed by train
  5. booking threadclaims a berth in PostgreSQL
  6. payment-serviceRazorpay order, signed webhook

Why it cannot double-book

Each claim locks its row with FOR UPDATE SKIP LOCKED, so claims arriving together step over each other instead of taking the same berth. A repeated request is stopped by a unique constraint, never by checking first.

Why the answer comes a moment later

The request only joins a queue. Holding a thread and a database connection for everyone waiting would exhaust the pool in the first second of a rush, so the page asks for its answer, and the server says when to ask again.

What load testing found

One thread doing all the booking, a lock inside a Redis library, a session made on every request, nginx running out of ports, and a query reading 172,512 rows to claim one berth. Each one fixed and measured.