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 herd → token 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
1 public final class SegmentKey { public final String runId; public final int fromSeq; public final int toSeq; }
1 def 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
1 export interface Pnr { id: string; segments: SegmentLease[]; status: "CONFIRMED" | "WL"; } 2 export 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
Section Rescue Kit
Buzzwords to use:
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."