AlgoViz

Design Ticketmaster

hard 55 min

Sell numbered seats to far more people than there are seats.

Video lesson · Chapter 1 of 6

One hold covers two seats

0:00 / 5:24

Theory

Read or listen first. About 1 min.

What it is

A ticket seller lets people find an event, pick numbered seats on a map, pay, and receive tickets that open the door. A service like Ticketmaster, SeatGeek or AXS does this.

Each seat exists once and cannot be restocked. On most days that is easy. When a famous artist sells out a stadium, millions want the same thousands of seats in the same minute, and the design is about that minute.

Why it exists

Selling one seat twice puts two people in front of one chair. Failing under the crowd loses a sale that will not come back and angers fans. Both must be prevented at once.

The same shape appears in hotel rooms, flights, restaurant tables and clinic appointments: hold something unique for a short time, then confirm or give it back.

A short history

  1. 1976

    Ticketmaster is founded in Phoenix, Arizona, and licenses ticketing programs and hardware.

  2. 2016

    The BOTS Act makes it illegal in the United States to get around ticket sellers' controls with software.

  3. 2022

    A presale for a stadium tour draws a reported 14 million visitors against 1.5 million prepared for, and the site fails within an hour.

Words to know

Hold
A seat kept for one shopper for a short time.
Oversell
Selling the same seat to two people.
Waiting room
A page where people wait outside the shop and are let in at a steady pace.
Admission rate
How many people a minute may enter.
Authorise and capture
Reserve money on a card first, take it later.
Idempotency key
A value that makes a repeated request have the effect of one.
Compensation
A step that undoes an earlier one, such as a refund.
Outbox
Messages saved in the same transaction as the change they announce.

Solve it like an interview

New to it? Start with Approach. Revising? Go straight to the mock.

  1. 1ApproachWhat this question tests, where it gets hard, and how to spend the time.
  2. 2ScopeAsk what changes the design, then commit to a short list.
  3. 3NumbersWork out a number when the answer changes what you build.
  4. 4API and dataThe contract first, then the data that serves it.
  5. 5DesignStart with the smallest system that works. Change it only when something breaks.
  6. 6Deep divesCompare the options before you open them, then say which you would pick.
  7. 7Explain your choicesAnswer first. Then compare your reasoning.
  8. 8By levelThe same question is judged differently for mid, senior and staff.
  9. 9MockAnswer against the clock, then score yourself.

How it works

Step through the idea, or press Play.

Step 1 of 3

Wait. A shuffled line, and a steady door

Understand it

Four numbered ponies
1234Four numbered ponies

A ribbon is a promise with an end. A rosette is for ever.

Scope

What are we building?

Search for events, look at a seat map, hold seats, pay, get tickets. The interesting case is one sale with 14 million people and 50,000 seats. General crowd control is in flash sale, and stock that is not numbered in inventory.

  • One seat, one owner

    Never sold twice, whatever fails.

  • A fair door

    Fast lines and scripts win nothing.

  • Safe money

    No charge without a seat, no double charge.

Similar applications

ServiceWhat is unique
SeatGeek, AXSSeats at events
StubHubResold tickets
EventbriteEvents by small organisers
Booking.comHotel rooms by night
OpenTableTables by time
Airline seatsSeats on a flight
Flash salesA small stock at a fixed minute

The hard part

Two problems that look like one

The crowd is a load problem: 1.5 million requests a second for a quarter of an hour. The seat is a contention problem: two people, one row. Mixing them leads to exotic locks. Once the door lets in 1,667 people a minute, only about 83 holds a second reach the seats, and an ordinary transaction is enough.

The finished system

Where the design ends up

The whole system

Fans reach a CDN edge and a gateway. Browsing goes to the event service with a search index and Redis. A sale sends fans through the waiting room. Inventory holds seats in the seat database, checkout sells them and calls a card provider outside our system, and an event stream feeds tickets, e-mail and analytics.
Blue is browsing, orange the waiting room, pink holding and buying. Dashed means later.

Where each idea lives

IdeaRead
Two writers, one rowConcurrency control, isolation levels
Many misses at onceThundering herd
Retries and keysIdempotency
Steps that can be undoneSaga
Pages near the fansCDN, cache-aside
SearchFull-text search, or the Yelp problem for places nearby
Limits for each clientAPI rate limiter
The interview, tab by tabApproach, Scope, Numbers, API, Design, Deep dives, Choices, Levels, Mock

Summary

The whole topic in one minute.

The crowd and the seat are two problems. A waiting room served from the edge lets in only as many people as the shop can serve. Inside, seat holds are so few a second that one database decides them safely with a short transaction.

Buying moves a seat from held to paying to sold. Money is reserved before the sale is written and taken after. A unique rule on tickets is the last guard, and everything slow happens after the commit.

  • Separate the crowd from the seat.
  • Shuffle the lobby, then call places with one public number.
  • A hold is a state and an end time in the seat's own row.
  • Authorise, sell in one transaction, then capture.
  • Only an answer from the provider frees a seat that is being paid for.

Sources