Design Train Ticketing & ETA System

Hard45 min
1 / 30
understanding9 min read

Problem Statement: Train Ticketing & Live ETA

Problem Statement: Train Ticketing & Live ETA — train ticketing interview depth

Problem Statement: Train Ticketing & Live ETA

Design IRCTC / Amtrak-class train ticketing: journey search, berth-level seat maps, segment-based inventory, Tatkal flash windows, waitlist promotion, and fused live ETAs. This section covers problem statement: train ticketing & live eta in the understanding phase.

Operational detail

Assume 23M registered users, 800K bookings/day, 13K concurrent train runs, Tatkal 20K bookings/min in the opening burst. Search is ~2K RPS average with 15× morning peak; holds expire in 7–10 minutes. Store hot inventory in Redis cluster shards per train run, authoritative rows in PostgreSQL with optimistic versioning. Telemetry ingest ~1.3K events/s (13K trains / 10s GPS). CAP: CP for PNR + seat ledger, AP for live map positions with STALE badges past 45s ping age.

Failure and edge cases

  • Double booking when two holds pass allocator without version check → reject with 409 INVENTORY_STALE
  • Tatkal thundering herdtoken bucket per user + server-side queue fairness
  • Partial multi-leg failure → saga releases all segment holds
  • GPS dropout in tunnels → widen ETA band; show schedule fallback source
  • Waitlist race on cancellation → single-threaded promote per coach class via outbox

Interview checkpoints

javaOne Dark Pro
1public final class SegmentKey { public final String runId; public final int fromSeq; public final int toSeq; }
pythonOne Dark Pro
1def segments_overlap(a_from: int, a_to: int, b_from: int, b_to: int) -> bool:
2 return max(a_from, b_from) < min(a_to, b_to) # order 1
typescriptOne Dark Pro
1export interface Pnr { id: string; segments: SegmentLease[]; status: "CONFIRMED" | "WL"; }
2export function holdKey(runId: string, coach: string): string { return `hold:${runId}:${coach}`; }

Numbers to say aloud

  • Tatkal: 20K bookings/min ≈ 333 holds/s sustained for ~5 minutes (size DB connection pools accordingly).
  • Segment index: O(stations²) per run precomputed; hot path is O(log n) shard lookup, not full table scan.
  • ETA target: p95 error < 90s when live; schedule-only band when ping age > 60s.

Why interviewers care

Train Ticketing & ETA System interviews reward crisp scope, explicit trade-offs, and failure stories—not generic microservice diagrams.

Interview checkpoint

Name one failure story for Problem Statement: Train Ticketing & Live ETA that proves you understand real outages, not happy-path diagrams.

Key Highlights

  • focus for sec-01
  • CP inventory vs AP live ETA
  • Quantify Tatkal before picking queues
Interview tip
Mention Tatkal opens as a timed quota window with queue fairness, no when discussing Problem Statement: Train Ticketing & Live ETA.
Avoid
Treating trains like flights without segment overlap or Tatkal queue fairness.

Section Rescue Kit

Buzzwords to use:

PNRTatkal

Safe statements:

  • "For Problem Statement: Train Ticketing & Live ETA, I separate CP seat ledger from AP live train position."
  • "I quantify Tatkal RPS before naming Kafka vs SQS."
Design Train Ticketing & ETA System - System Design | WinJob | WinJob