All questions
Medium2026-09-04

Design a Bus Booking System (like RedBus)

Company
Rakuten
Role

SDE (Java)

Round

Round 2 (HLD)

System DesignConcurrencyDatabase Design

Problem Statement

Design a bus booking system similar to RedBus. Users should be able to search for buses by source, destination, and time, then book seats. The system must handle concurrent bookings safely.

Requirements

Functional:

  • Search buses by source, destination, date/time
  • View available seats for a bus
  • Book one or more seats
  • Handle payment and confirmation
  • Send booking notifications

Non-Functional:

  • Two users must NOT be able to book the same seat simultaneously
  • Search should be fast
  • Reliable notifications

What the Interviewer Expects

  1. Search design — index buses by (source, destination, date). Discuss how to efficiently query routes and available seats.
  2. Seat booking concurrency (the key focus):
    • The classic problem: two users select the same seat at the same time
    • Pessimistic locking: lock the seat row during booking (SELECT FOR UPDATE)
    • Optimistic locking: version/status check — seat has a status (available/locked/booked); use atomic compare-and-set
    • Temporary hold: lock the seat for N minutes during payment, release if payment fails
  3. Data model — buses, routes, schedules, seats, bookings, users tables.
  4. Notification system — async via message queue (booking confirmation, reminders). Decouple from the booking flow.
  5. Payment flow — hold seat → process payment → confirm or release on timeout.

Follow-ups

  1. How do you handle a seat held during payment when the user abandons checkout?
  2. How would you prevent overselling during high-demand routes (festival season)?
  3. How would you design the notification system to be reliable (at-least-once delivery)?
  4. How do you scale search for millions of routes and queries?
  5. How would you handle dynamic pricing based on demand?
🧠

No solution provided

Think through it. That's how you build real interview muscle.

Share: