Hide sidebar

Design Ticketmaster

Easy
Design a ticket booking system like Ticketmaster. The system should allow users to browse events, select seats, and purchase tickets. It must handle high-traffic scenarios, such as when tickets for a popular event go on sale, and prevent issues like double-booking.

Variants:

EventbriteSeatGeekLive Nation
Loading diagram...

Ticketmaster System Design Requirements

Functional Requirements

1

Event Browsing

Users should be able to browse and search for events by name, venue, city, and date.

2

Seat Selection

Users should be able to view an interactive seat map and select their desired seats.

3

Ticket Purchasing

Users should be able to purchase tickets using a secure payment gateway.

4

Order Management

Users should be able to view their order history and access their tickets.

Non-Functional Requirements

1

High Availability

The system must be highly available, especially during high-traffic sales events.

2

Low Latency

Seat selection and locking should be near real-time to prevent double-booking.

3

Scalability

The system must be able to handle massive traffic spikes when popular events go on sale.

4

Consistency

The system must ensure that a seat cannot be sold to more than one person.

CAP Theorem Trade-offs

ConsistencyAvailabilityPartition Tolerance
Trade-off Explanation:

For a ticket booking system, we prioritize Consistency and Partition Tolerance (CP). It's absolutely critical that a seat is not sold to more than one person, so we cannot compromise on consistency. If there is a network partition, we would rather have the system be unavailable than to sell the same seat twice.

Scale Estimates

User Base100M users (10^8)
Base assumption for system sizing
Tickets Sold/Year500M tickets (5 * 10^8)
The number of tickets our system must handle annually.
Peak Traffic1M users/minute
Events per Year100K events
Seats per Event10K seats
Total Seats1B seats

API Design

The API for our ticket booking system will be more complex than a simple URL shortener. We'll need endpoints for browsing events, viewing seat maps, locking seats for purchase, and processing payments.

The core of the API will revolve around the user flow of selecting an event, choosing seats, and completing the purchase. We'll need to handle seat locking to prevent multiple users from purchasing the same seat, and we'll need to integrate with a payment gateway to process transactions.

GET/api/v1/events

Get a list of events, with optional filtering

GET/api/v1/events/{event_id}/seats

Get the seat map for a specific event

POST/api/v1/seats/lock

Lock a seat for purchase

POST/api/v1/checkout

Purchase a locked seat

Database Schema

Our database schema will be more complex than the previous examples, as we need to manage events, venues, seats, users, orders, and payments.

We'll have separate tables for each of these entities, with foreign key relationships to link them together. The seats table will be the most critical, as it will store the status of each seat (available, locked, sold) and will be the source of truth for our booking system.

events

event_id
stringPartition Key
title
string
artist_id
string
venue_id
string
date
timestamp

seats

seat_id
stringPartition Key
event_id
string
section
string
row
string
number
string
status
string
lock_id
string
order_id
string

orders

order_id
stringPartition Key
user_id
string
event_id
string
seat_id
string
amount
decimal
payment_status
string
created_at
timestamp

High-Level Architecture

At the heart of our system, we'll have a set of core microservices responsible for handling the key business logic. Your interviewer will expect you to break down the system into logical components, and a microservices architecture is a natural fit for a system like Ticketmaster.

Core Services

  • Ticket Catalog Service: This service is responsible for managing all event and venue information. It will expose endpoints for searching for events, viewing event details, and retrieving seat maps. This service will be read-heavy, so we can optimize it for fast reads by using caching and a denormalized data model.

  • Booking Service: This service is responsible for the entire ticket booking workflow. It will handle seat locking, payment processing, and order creation. This service is write-heavy and requires strong consistency guarantees to prevent double-booking. Your interviewer will likely want to dig into the details of how you handle concurrency and atomicity in this service.

Deep Dive: Seat Locking

In a system design interview, the topic of seat locking is almost guaranteed to come up when discussing a ticket booking system. Your interviewer will want to see that you've thought about the challenges of preventing double-booking in a high-concurrency environment. There are two main approaches to this problem: pessimistic and optimistic locking.

1

Pessimistic Locking with a Database

Why: Pessimistic locking is a straightforward approach where we lock the seat in the database as soon as a user selects it. This prevents any other user from accessing the seat until the lock is released.

How it works: When a user selects a seat, we update the status of the seat in the seats table to locked and set a lock_id and expires_at timestamp. If another user tries to select the same seat, the database will prevent them from doing so. If the user completes the purchase, we update the status to sold. If they abandon the purchase or the lock expires, we update the status back to available.

Trade-offs:

  • Pros: Simple to implement, strong consistency guarantees.
  • Cons: Can lead to a lot of database contention, especially during high-traffic sales. A user could lock a seat and never complete the purchase, holding up the seat for other users.
2

Optimistic Locking with a Key-Value Store

Why: Optimistic locking is a more scalable approach that avoids holding long-lived locks in the database. Instead, we use a version number or timestamp to detect conflicts.

How it works: When a user selects a seat, we retrieve the current version number of the seat from a key-value store like Redis. When the user tries to purchase the seat, we check if the version number is still the same. If it is, we update the seat status and increment the version number. If the version number has changed, it means another user has already purchased the seat, and we return an error.

Trade-offs:

  • Pros: More scalable than pessimistic locking, less database contention.
  • Cons: More complex to implement, requires careful handling of race conditions.

Deep Dive: Handling High-Traffic Sales

Your interviewer will almost certainly ask how you would handle the massive traffic spikes that occur when tickets for a popular event go on sale. This is a classic system design question that tests your understanding of scalability and user experience. A virtual waiting room is a common and effective solution to this problem.

1

Virtual Waiting Room

Why: A virtual waiting room is a common strategy for managing high-traffic events. It allows us to control the number of users who can access the booking system at any given time.

How it works: When a user tries to access the booking page, they are placed in a virtual waiting room. We then let users into the booking system at a controlled rate, ensuring that our servers are not overwhelmed. This provides a much better user experience than simply letting the site crash.

Trade-offs:

  • Pros: Prevents server overload, provides a fair and orderly process for users.
  • Cons: Can be frustrating for users who have to wait a long time. Requires additional infrastructure to manage the waiting room.

CAPTCHA and Bot Protection

High-traffic sales are a prime target for bots that try to scoop up all the best tickets. We need to have a robust bot protection strategy in place.

  • CAPTCHA: We can use a CAPTCHA service like reCAPTCHA to ensure that only human users can access the booking system.
  • Rate Limiting: We can rate limit requests from individual IP addresses to prevent a single user from overwhelming the system.
  • Behavioral Analysis: We can use machine learning to analyze user behavior and identify patterns that are indicative of bot activity.

Complete Design

Now that we've covered all the major components individually, let's look at how everything fits together in our complete Ticketmaster system design. This diagram shows the end-to-end flow from a user searching for an event to purchasing a ticket.

Loading diagram...

The complete architecture demonstrates how users interact with the Ticket Catalog Service to find events and the Booking Service to handle the entire booking workflow. This design ensures a scalable, reliable, and fair system for selling tickets to high-demand events.