Design a Ticket Booking System: Junior, Senior, and Staff Answers
When you hear "design a ticket booking system" in an interview, the recruiter is looking for three things: how you reason about scale, how you balance consistency with performance, and whether you think about the system after it ships. The problem is deceptively simple – a user selects seats, pays, and receives a confirmation – but the devil is in the details of handling high-volume traffic, preventing double-booking, and keeping the service cheap to run.
What the Interviewer Is Testing
- Scalability – can you estimate traffic spikes and size the components?
- Data consistency – how will you guarantee that two users cannot book the same seat?
- Operational mindset – do you consider monitoring, alerting, and cost?
- Communication – can you walk through a request path step-by-step and explain each decision?
Core Requirements and Driving Numbers
| Requirement | Why it matters | Rough figure (hedged) |
|---|---|---|
| Functional | Users must view events, select seats, pay, and get a ticket. | – |
| Performance | Latency should feel instant; sub-second page loads. | |
| Consistency | No double-booking; strong write guarantee. | |
| Availability | System should stay up during ticket releases (often a few hours of intense traffic). | – |
| Traffic | Assume a popular concert sells 100,000 tickets in 2 hours. | |
| Peak QPS | 100,000 tickets / 2 h ≈ 14 tickets/second. Add browsing, retries, and other events → roughly 50 QPS. | |
| Data size | Seat map for a stadium: ~200,000 seats, each row/section metadata a few KB → under a gigabyte total. | |
| Durability | All bookings must be persisted; loss is unacceptable. |
These numbers guide the choice of storage, caching, and messaging layers.
Core Design Walkthrough
Below is a single request path for a user buying a seat.
- Client → API Gateway – The web or mobile client hits an Amazon CloudFront distribution that forwards the request to an Amazon API Gateway endpoint. CloudFront caches static assets (event pages, images) and reduces latency.
- API Gateway → Lambda (or ECS) – A thin Lambda function validates the request (user auth, seat format) and forwards it to the booking service.
- Booking Service → DynamoDB (Seat Table) – The service attempts a conditional write:
PutItemwith a condition that the seat’sstatus = AVAILABLE. DynamoDB’s strong consistency on a single item guarantees no two writes succeed. - Success → Payment Service – On a successful seat reservation, the service publishes a message to an Amazon SQS queue (or Kafka on MSK) that triggers the payment workflow. The payment service deducts the amount, updates the order record, and writes the final status.
- Payment Service → DynamoDB (Order Table) – The order record is stored in a separate DynamoDB table. A successful payment also writes a confirmation email to an S3 bucket that triggers an SNS notification.
- Response → Client – The Lambda returns a JSON payload with the ticket ID and a URL to the PDF stored in S3. The client shows a confirmation screen.
Data Model Sketch
- Event –
event_id,name,date,venue_id. - Venue –
venue_id,capacity,seat_map(JSON or separate Seat table). - Seat –
seat_id,event_id,status(AVAILABLE, RESERVED, SOLD),price. - Order –
order_id,user_id,seat_id,payment_status, timestamps.
Key Choices
- DynamoDB for seat inventory – Chosen for its low-latency conditional writes and ability to scale to millions of requests without sharding. Alternatives like Aurora would require explicit row locking and could become a bottleneck under burst traffic.
- SQS vs. Kafka – SQS gives at-least-once delivery with minimal ops overhead; Kafka on MSK is useful if you need replayability for analytics, but adds operational complexity.
- ElastiCache (Redis) for read-heavy pages – Event listings and seat maps are cached to offload DynamoDB reads. Cache invalidation happens after a successful reservation.
What a Complete Junior Answer Covers
- Lists functional requirements (view events, select seats, pay).
- Mentions non-functional goals (latency < 1 s, availability > 99.9%).
- Draws a simple flow: client → load balancer → web server → relational DB.
- Uses a single MySQL/Aurora instance for both seat inventory and orders.
- Talks about primary key (
event_id, seat_id) and a basic transaction to lock a seat. - Acknowledges scaling by adding read replicas.
- No mention of caching, async payment, or failure isolation.
What a Senior Answer Adds
- Introduces conditional writes in DynamoDB to avoid double-booking without explicit locks.
- Adds ElastiCache for hot reads of seat maps and event data.
- Splits write path (booking) from payment path using SQS to decouple latency-sensitive reservation from slower payment processing.
- Discusses idempotency – a client retry includes a unique request ID stored in DynamoDB to prevent duplicate reservations.
- Shows a simple monitoring stack: CloudWatch metrics on DynamoDB throttles, Lambda error rates, and SQS queue depth.
- Considers horizontal scaling: API Gateway + Lambda auto-scales, DynamoDB partitions automatically.
What a Staff Answer Adds
- Failure modes – detailed analysis of what happens if DynamoDB throttles, SQS latency spikes, or the payment gateway times out. Includes circuit-breaker pattern and fallback to a “reservation queue” persisted in DynamoDB.
- Operational concerns – cost breakdown (DynamoDB read/write capacity, Lambda invocations, S3 storage for PDFs). Shows how on-demand capacity (or provisioned capacity with auto scaling) keeps costs low during off-peak periods.
- Data consistency trade-offs – explains why strong consistency on a single item is sufficient, and why eventual consistency is acceptable for event listings.
- Geo-distribution – uses CloudFront edge caching and possibly DynamoDB Global Tables for multi-region read replicas when serving a global audience.
- Capacity planning – runs the numbers: 50 QPS → 4,320,000 requests per day; DynamoDB on-demand absorbs that without capacity planning, and roughly 130 million requests a month cost on the order of tens of dollars in request charges.
- Security – IAM roles for Lambda, encryption at rest for DynamoDB, TLS for API Gateway.
- Testing & rollout – blue-green deployment using AWS CodeDeploy, canary releases, and feature flags.
Common Mistakes That Sink the Question
| Mistake | Why it hurts |
|---|---|
| Using a single relational DB without locking | Leads to race conditions and double-booking under load. |
| Ignoring write-read separation | Payment latency blocks seat reservation, causing timeouts. |
| No caching | Reads hit the DB directly, inflating latency and cost during ticket releases. |
| Over-engineering | Adding micro-services or complex pipelines before the basic consistency problem is solved wastes time. |
| Skipping idempotency | Retries from the client create duplicate orders or inconsistent state. |
How to Practice This
- Study the worked design in the System Design AI library. It opens on a step-by-step walkthrough, and every component on the board can be clicked for its notes.
- Create your own canvas: sketch the flow, label each AWS service, and write a brief note on why you chose it.
- Run a mock interview: explain the junior, senior, and staff perspectives out loud, then compare to the rubric provided in the practice brief.
Questions people ask
How do you prevent double-booking in a ticket system?
Use a storage layer that supports conditional writes, such as DynamoDB's PutItem with a condition that the seat status is AVAILABLE. The write succeeds only for the first request, guaranteeing uniqueness without explicit locks.
Why separate the reservation step from the payment step?
Reservation must be fast and reliable; payment can be slower and may fail. Decoupling them with a message queue (SQS or Kafka) lets the booking service return a confirmation quickly while the payment service processes asynchronously.
What AWS service should cache seat maps for read-heavy traffic?
Amazon ElastiCache (Redis) is ideal for caching hot data like seat maps and event listings. It reduces read pressure on DynamoDB and serves sub-millisecond responses from memory.
When is a relational database appropriate for this design?
A relational DB like Aurora is a sound choice at the estimated load: a transaction with a row lock, or a conditional UPDATE that only succeeds while the seat is AVAILABLE, prevents double-booking. It needs more care during an on-sale burst (connection limits, contention on popular seats). DynamoDB's partitioning and conditional writes scale more naturally for high-volume ticket sales.