System Design

Problem Breakdowns

Ticketmaster and Event Ticket Booking

Everyone designs a lock for the seat. Even a stadium that sells out in 10 minutes sells only a few dozen orders a second, so the seats are not the hard part. The hard part is the crowd that will not get one, and the line that decides who tries first.

"Design Ticketmaster" usually turns into an argument about a lock. Two people click the same seat, so the candidate locks it, in Redis with a timeout or in the database with SELECT ... FOR UPDATE. Then they spend the rest of the interview defending the lock. The lock is necessary. It's also about 10 lines of SQL, and it isn't where this system gets hard.

Start with Ticketmaster's own figures. A stadium show has about 50,000 seats, and Ticketmaster says it usually takes about an hour to sell one out. That's 14 tickets a second. A show that sells out in 10 minutes sells 83 tickets a second, or about 28 orders. One database handles that easily.

Then look at who is asking. When the presale for Taylor Swift's Eras Tour opened in November 2022, Ticketmaster's systems received 3.5 billion requests, many of them from bots. From that traffic, Ticketmaster estimated demand for more than 900 stadium shows, nearly 20 times the shows on sale. Counting people gives a smaller number that makes the same point. 3.5 million people registered, and at about 3 tickets each they wanted about four times the 2.4 million tickets the presales sold.

Even a stadium that sells out in 10 minutes sells only a few dozen orders a second, so the database that holds the seats never needs to be fast. The design work is in the line in front of it: who gets a turn, in what order, and how everyone else is kept away from the seats.

The rest of the design follows from that. The seats live in an ordinary relational database such as Postgres, split across machines so that one failure stops few sales, not to make it faster. The live seat map only has to serve the few thousand people inside the sale. And stopping bots becomes a question about accounts in a line, not about requests per second.

The on-sale at a glance
Fans join the line before the sale opens (1). When it opens, each gets a random place, and the line lets people in as space opens up (2). Only people with a turn reach the booking service, which holds seats in Postgres (3) and takes payment through Stripe (4). The seat drawing and a snapshot of free seats come from the content delivery network, the CDN (5), so the crowd in the line never touches the database.Fans join the line before the sale opens (1). When it opens, each gets a random place, and the line lets people in as space opens up (2). Only people with a turn reach the booking service, which holds seats in Postgres (3) and takes payment through Stripe (4). The seat drawing and a snapshot of free seats come from the content delivery network, the CDN (5), so the crowd in the line never touches the database.
Hundreds of thousands wait in the line, and a thousand a minute reach the seats. Fans join the line before the sale opens (1). When it opens, each gets a random place, and the line lets people in as space opens up (2). Only people with a turn reach the booking service, which holds seats in Postgres (3) and takes payment through Stripe (4). The seat drawing and a snapshot of free seats come from the content delivery network, the CDN (5), so the crowd in the line never touches the database.

Understanding the problem

The general method for this part of the interview is in The First Five Minutes: Requirements.

Ticketmaster sells tickets to live events: concerts, sports and theatre. A venue releases the seats for a show, buyers choose seats and pay, and each ticket is scanned at the door. Ticketmaster sold more than 620 million tickets in 2023, according to Live Nation's annual results.

People mean five different systems when they say "Ticketmaster", and each one needs a different design.

  1. Discovery. Searching and browsing events. It's a search index, such as Elasticsearch, and it only reads.
  2. The ordinary sale. Selling a show's seats on a normal day. A buyer holds some seats, pays, and gets tickets.
  3. The on-sale. The moment tickets for a popular show are released, and the minutes after, when many more people want seats than exist. The seats and the payments are the same as in an ordinary sale. The difference is the crowd in front of them.
  4. Resale. Fans selling tickets they bought to other fans. It's a marketplace, with listings and prices of its own.
  5. Entry. Putting the ticket on a phone and scanning it at the gate.

This design covers the ordinary sale and the on-sale, and nearly all the difficulty is in the on-sale.

Functional requirements

Core:

  1. Hold seats. A buyer chooses seats, or a section and a number of seats, and they're kept for that buyer for a few minutes while they pay. No seat is ever sold to two buyers.
  2. Buy them. The buyer pays, and the held seats become tickets.
  3. Wait fairly during an on-sale. Everyone who comes for a high-demand sale gets a place in a line, by a rule they can be told. Only people whose turn has come can reach the seats.
  4. See which seats are free. A seat map shows what can still be bought.

Out of scope, deliberately:

  • Search and discovery. Nothing in it touches a sale.
  • Resale, transfers between fans, and refunds when a show is cancelled.
  • Entry: delivering tickets to phones and scanning them.
  • Pricing, including prices that change with demand, and the tools promoters use to set up a show. The sale reads a price. It doesn't decide one.

Non-functional requirements

  1. No seat is sold twice, not even rarely. If two people hold tickets for one seat, they meet at the seat, and nothing done afterwards fixes it.
  2. Only people with a turn reach the seats. During an on-sale, the line answers everyone else, and the database that holds seats never sees them.
  3. Scale. 620 million tickets a year is about 20 a second on average. On-sale peaks are set by people, not seats.
  4. Fast enough for a person. A hold is answered within a second at p99, which means 99 of every 100 holds. The seat map may be a few seconds behind.
  5. Browsing and the line stay up when checkout is in trouble. A slow card processor should slow the sale down, not take the site with it.

Requirement 2 carries the design. Candidates often add it late, as a waiting room in a deep dive. Here it makes requirements 1 and 4 cheap, because it sets how many people can write seats or read the map at the same moment.

Back of envelopeThe seats against the people
How fast can one stadium show sell, and how many people
are asking? Work out the rate the seats allow first.

One stadium show
  seats                                          50,000
  Ticketmaster: about an hour to sell one out
    50,000 / 3,600 s                     ≈ 14 tickets/s
  Ticketmaster says Verified Fan buyers average
  about 3 tickets
    14 / 3                               ≈  5 orders/s

The same show, sold out in 10 minutes
  50,000 / 600 s                         ≈ 83 tickets/s
    83 / 3                               ≈ 28 orders/s
  one Postgres primary commits      5,000 to 20,000/s

People asking, this example's stress case
  Ticketmaster's traffic estimate, bots included:
  demand for about 20x the shows on sale
  tickets wanted   50,000 × 20              = 1,000,000
  people           1,000,000 / 3            ≈   330,000
  orders possible  50,000 / 3               ≈    16,700
  (the registrations alone suggest about 4x, not 20x)
  ─────────────────────────────────────────────────────
Even a 10 minute sellout is 28 orders a second, a small
load for one database. In the stress case, about 1
person in 20 can get tickets, and the others have to be
told no, however fast the system is.

The set up

Core entities

  • Event. One show, at one venue, at one time, with the time its sale opens.
  • Seat. One row per seat per show: section, row, number, price, and a status. This is the only entity two buyers ever try to write at the same moment, so most of the design is about it.
  • Order. One buyer's attempt to buy some seats. It owns the hold, and it carries the payment.
  • Ticket. Created once the order is paid. It's what gets scanned at the door.
  • Place in line. During an on-sale, a buyer's position, and later the admission that lets them shop. It lasts minutes.

The drawing of the venue, where every seat sits on the map, belongs to the venue's layout, not to the show. It doesn't change during a sale.

Shows are set up ahead of time, through a small control plane. A promoter creates the show, loads its seats from the venue's layout, and sets prices, a ticket limit per account and whether the sale uses a line. That's ordinary create, read, update and delete (CRUD), done days before. The sale only reads those settings.

The line and the seat map both look live, and both are polled. Each is state rather than a stream of events, the dashboard case in WebSockets, SSE and Polling.

System interface

LINE
POST /v1/events/evt_7/line                        join, once per account
GET  /v1/events/evt_7/line/me      → { "position_ticket": "eyJwb3Mi..." }
GET  /v1/events/evt_7/serving      → { "serving": 41200, "state": "OPEN" }
                                     Cache-Control: max-age=1
POST /v1/events/evt_7/admit          { "position_ticket": "eyJwb3Mi..." }
                                   → { "admission": "eyJhY2Mi...", "expires_in": 600 }

SALE
POST /v1/events/evt_7/holds
Authorization: Admission eyJhY2Mi...
Idempotency-Key: 9b1e4c2a-...-77c0
{ "section": "112", "quantity": 3 }     or    { "seats": ["112-B-14", "112-B-15", "112-B-16"] }

201 Created
{ "order_id": "ord_42",
  "seats": ["112-B-14", "112-B-15", "112-B-16"],
  "held_until": "2026-11-01T10:14:03Z" }

POST /v1/events/evt_7/orders/ord_42/pay
Idempotency-Key: 3f7a90d1-...-0d21
{ "payment_method": "pm_1Q..." }

Four things to note.

The line's only shared value is serving. A page learns its own position once, inside a signed ticket. From then on it asks one question: how far has the line moved? The answer is the same for everyone waiting for that show, so a content delivery network (CDN) can answer it from a one second cache.

The admission is needed for the hold, and only for the hold. It's signed, it names the account, and it expires, so the hold endpoint checks a signature and a time and reads nothing about the line. Paying, confirming and releasing need the signed-in account to own the order instead. An admission that expires halfway through checkout then changes nothing.

The hold names an order, not a buyer, and it returns its deadline. ord_42 owns the hold, so a retry from the same order finds its own hold, and a late release can't free seats that now belong to someone else. held_until is the countdown the buyer sees.

Every order call names its show. The show decides which shard holds the order, so ord_42 sits under evt_7 in every path. The booking service also puts event_id in the Stripe payment's metadata, so a webhook from Stripe can find the shard too.


High-level design

The hold comes first because it's the one place two buyers write the same data.

1. How do two buyers never get the same seat?

A buyer picks three seats. Up to 5 minutes can pass between that click and the payment, while they type card details and approve the payment in their bank's app. During those minutes nobody else may buy those seats. And if the buyer walks away, the seats have to come back on sale.

Naive

Lock the seat rows until the payment finishes

Open a transaction, lock the three seats with SELECT ... FOR UPDATE, wait for the buyer to pay, mark the seats sold and commit. It's tempting because the database already has locks, and if anything fails, the rollback gives the seats back on its own.

The lock holds a database connection for the whole checkout. Little's law, from Latency Numbers That Matter, says how many: the number in flight equals the arrival rate times how long each one stays. At the rate the line lets people in, about 17 holds a second (section 3 sets it), each holds its connection for up to 300 seconds. That's about 5,000 open transactions against a connection pool of about 100. The pool is full in 6 seconds, and the next buyer waits for a connection, not for a seat.

The usual repair is to move the lock into Redis, SET seat:evt_7:112-B-14 ord_42 NX PX 600000, which expires on its own and holds no connection. It also puts the truth about a seat in two places. Redis copies writes to its replica after acknowledging them, so a failover can lose a lock granted a moment earlier, and then a second buyer holds the same seat. The database needs its own check at the sale anyway. The second data store adds a way to be wrong and removes no work.

Senior

Hold the seat in its own row, with an owner and a deadline

This is the hold Distributed Transactions and Sagas builds. The seat row carries status = 'HELD', the order that owns the hold in held_by, and a deadline in held_until, 10 minutes ahead. A hold is one conditional write: it succeeds only if the seat is free, its old hold has expired, or this order already holds it.

An order holds several seats, so the hold covers all of them or none:

BEGIN;
UPDATE seats
SET status = 'HELD', held_by = 'ord_42',
    held_until = now() + interval '10 minutes'
WHERE event_id = 'evt_7'
  AND seat_id IN ('112-B-14', '112-B-15', '112-B-16')
  AND (status = 'AVAILABLE'
       OR (status = 'HELD'
           AND (held_until < now() OR held_by = 'ord_42')));
-- 3 rows updated: COMMIT. Fewer: ROLLBACK, and the buyer picks again.
COMMIT;

If fewer than three rows change, someone else took one of the seats, and the rollback means this buyer never holds two of the three. The transaction lasts milliseconds, so it holds no connection and no lock during checkout. An expired hold counts as free, so no cleanup job is needed. The hold is data.

A seat's three states
A hold moves a seat from AVAILABLE to HELD for one order, with a deadline (1). The confirm moves it to SOLD, but only if the same order still holds it and the deadline hasn't passed (2). A release by the owner sends it back (3). A hold whose deadline has passed is treated as AVAILABLE by the next hold, so the dashed path back needs no job.A hold moves a seat from AVAILABLE to HELD for one order, with a deadline (1). The confirm moves it to SOLD, but only if the same order still holds it and the deadline hasn't passed (2). A release by the owner sends it back (3). A hold whose deadline has passed is treated as AVAILABLE by the next hold, so the dashed path back needs no job.
Each move is one conditional write, and an expired hold needs no write at all. A hold moves a seat from AVAILABLE to HELD for one order, with a deadline (1). The confirm moves it to SOLD, but only if the same order still holds it and the deadline hasn't passed (2). A release by the owner sends it back (3). A hold whose deadline has passed is treated as AVAILABLE by the next hold, so the dashed path back needs no job.

This is the standard answer, and it's correct. Its cost shows up in a rush. When thousands of buyers look at the same map, many of them click the same seats, and every click after the first fails.

Staff

During the rush, let the server choose the seats

Ask whether the buyer has to choose the exact seat. In the first minutes of an on-sale, everyone let in opens the same map and looks for the best seats they can afford. They all see the same best seats, so they click the same seats.

The first click wins and the others fail. In Postgres, a second UPDATE on a row that another transaction is changing waits a few milliseconds for that commit. Then it checks its WHERE again and changes nothing. The wait is short. The cost is the failure: each loser goes back to the map, picks again and clicks again, and in the first minutes most clicks lose.

So in the rush, the buyer chooses a section, a price and a quantity, and the server chooses the seats. One transaction locks the section's row, reads that section's free seats in order of quality, picks the best block of adjacent seats, and holds them:

BEGIN;
SELECT 1 FROM sections
WHERE event_id = 'evt_7' AND section_id = '112'
FOR UPDATE;                       -- one allocation per section at a time

SELECT seat_id, row_label, seat_no FROM seats
WHERE event_id = 'evt_7' AND section_id = '112'
  AND (status = 'AVAILABLE'
       OR (status = 'HELD' AND held_until < now()))
ORDER BY seat_rank;

-- the service picks the first 3 adjacent seats in one row,
-- then holds them with the senior tier's conditional UPDATE
COMMIT;

Allocations still queue, on the section's row instead of on seats, for a few milliseconds each, so a section can take a few hundred a second. But none of them fails while the section has seats, so there are no failed clicks to repeat. The final UPDATE is the same conditional write, so a seat taken some other way between the read and the write still can't be sold twice.

When a section has only scattered single seats left, no party of 3 fits together. The allocator then offers seats split across the section, or the best block in the next section, and the buyer chooses.

Everyone picks the same seats
On the left, five buyers look at the same map and click the same three seats in row B. The first hold wins (1). The other four fail, in red (2), and each one goes back to the map to try again. On the right, the same five ask for 3 seats in section 112, and the allocator gives each the next best block, in rows B, C and D (3). Every request succeeds, in green.On the left, five buyers look at the same map and click the same three seats in row B. The first hold wins (1). The other four fail, in red (2), and each one goes back to the map to try again. On the right, the same five ask for 3 seats in section 112, and the allocator gives each the next best block, in rows B, C and D (3). Every request succeeds, in green.
One map shown to everyone sends everyone to the same seats. On the left, five buyers look at the same map and click the same three seats in row B. The first hold wins (1). The other four fail, in red (2), and each one goes back to the map to try again. On the right, the same five ask for 3 seats in section 112, and the allocator gives each the next best block, in rows B, C and D (3). Every request succeeds, in green.

What you give up: in the rush, buyers can't pick the exact seat. Once the line is empty, the full seat map can come back, because two buyers then rarely want the same seat in the same second. And someone has to write the code that finds adjacent seats, which takes care in oddly shaped sections.

Which data store, and what forces it

The hold is a conditional write on a row, and the order is written beside it. That's what a relational database does well, so start with one Postgres.

Back of envelopeDoes one Postgres hold every show?
The plan is one Postgres for every show on the platform.
Check storage first, then the write rate on an ordinary
day and on the busiest morning of the year.

Storage
  tickets a year, Ticketmaster in 2023           620M
  rows per ticket sold, all tables and
  indexes included, assumed                     400 B
  620M × 400 B                          ≈ 250 GB/year

Writes, an ordinary day
  620M / 31.5M seconds in a year          ≈ 20 tickets/s

Writes, the busiest morning
  assumed: 50 stadium shows go on sale at 10:00. The
  line in section 3 lets in an assumed 1,000 people a
  minute per show, and 7 in 10 of them buy.
  holds        1,000 / 60 s                 ≈ 17/s
  paid orders  700 / 60 s                   ≈ 12/s
  commits per show
    17 holds + 12 × 3 later steps
    + ~5 releases                          ≈ 60/s
  50 shows × 60/s                           = 3,000/s
  one Postgres primary commits     5,000 to 20,000/s
  ─────────────────────────────────────────────────────
Storage fits one machine for years, and the busiest
morning fits one primary. So one machine could take
the load, and every on-sale on the platform would
share its failures.

The three later steps for a paid order are the move to authorising, the confirm and the capture. The releases are the 3 in 10 who leave, counted as if every one of them presses cancel.

Naive

One Postgres for every show

This is the right place to start, and the worksheet says it fits: about 250 GB a year, and 3,000 commits a second on the busiest morning.

The problem is that everything shares that primary. A failover takes from about 3 seconds to about 30, depending on how clients find the new primary, as Replication and Leader Election works out. During it, every on-sale on the platform stops at once. A runaway query from one show slows the checkout for every other show too.

Senior

Shard by show, with seats and orders together

Key seats, orders and tickets by event_id, the move Distributed Transactions and Sagas makes in its staff answer, and spread event ids across 64 shards by hash. A show's rows live on one shard, so the hold, the confirm and every other step of one booking is a single local commit. On the busiest morning, 3,000 commits a second across 64 shards is about 50 a shard.

The cost is every query that isn't about one show. "My tickets" needs one account's orders across all shows, and those sit on up to 64 shards. So an outbox, a table written in the same commit as the order and sent on afterwards, feeds a separate index of orders by account, a few seconds behind.

This is the standard answer, with the shards sized by load.

Staff

Choose the shard count by what one failure may stop

Question why there are 64 shards. The load would fit one primary: 3,000 commits a second on the busiest morning. So count shards by something else, the number of on-sales one failure may stop.

What one failure stops
Both rows hold the 50 shows that go on sale at 10:00. In the top row, two primaries hold 25 each, so a failover stops 25 on-sales at once, in red (1). In the bottom row, the directory places the shows on 64 shards, never two big ones together, so the same failover stops one, and the other 49 keep selling, in green (2).Both rows hold the 50 shows that go on sale at 10:00. In the top row, two primaries hold 25 each, so a failover stops 25 on-sales at once, in red (1). In the bottom row, the directory places the shows on 64 shards, never two big ones together, so the same failover stops one, and the other 49 keep selling, in green (2).
With 64 shards, a failover on the busiest morning stops about one on-sale. Both rows hold the 50 shows that go on sale at 10:00. In the top row, two primaries hold 25 each, so a failover stops 25 on-sales at once, in red (1). In the bottom row, the directory places the shows on 64 shards, never two big ones together, so the same failover stops one, and the other 49 keep selling, in green (2).

With one primary, a failover on the busiest morning stops all 50 on-sales. With two, it stops about 25. With 64 shards, it stops about one.

A big on-sale is a hot key you can see coming, because the date is set weeks ahead and registrations show the demand days before. So place shows through a directory, a small table from event id to shard, instead of a hash. Two big on-sales then never share a shard.

What you give up: 64 shards is about 250 Postgres instances. Each primary also has a standby in another zone, a copy in another region and a replica that the seat map is built from. Each primary is at most about 1 percent busy, even on the busiest morning. And every booking request reads the directory, cached in each booking server. Partitioning and Sharding covers what a directory costs once the router becomes part of the system.

The tables

Each shard holds these, for the shows the directory places on it:

CREATE TABLE sections (
  event_id     text,
  section_id   text,
  price_cents  int  NOT NULL,
  PRIMARY KEY (event_id, section_id)        -- the allocator locks this row
);

CREATE TABLE seats (
  event_id     text,
  seat_id      text,                        -- '112-B-14'
  section_id   text NOT NULL,
  seat_rank    int  NOT NULL,               -- lower is better
  status       text NOT NULL,               -- AVAILABLE | HELD | SOLD
  held_by      text,                        -- order_id
  held_until   timestamptz,
  PRIMARY KEY (event_id, seat_id)
);
CREATE INDEX seats_by_section ON seats (event_id, section_id, seat_rank);

CREATE TABLE orders (
  event_id     text,
  order_id     text,
  account_id   text NOT NULL,
  status       text NOT NULL,  -- HOLDING | AUTHORISING | CONFIRMED
                               -- | CAPTURED | CANCELLED
  quantity     int  NOT NULL,
  held_until   timestamptz NOT NULL,       -- same deadline as its seats
  payment_id   text,                       -- Stripe PaymentIntent
  PRIMARY KEY (event_id, order_id)
);
CREATE INDEX orders_by_account ON orders (event_id, account_id);

CREATE TABLE buyers (                       -- one row per account per show
  event_id     text,
  account_id   text,
  PRIMARY KEY (event_id, account_id)
);

CREATE TABLE tickets (
  event_id     text,
  ticket_id    text,
  seat_id      text NOT NULL,
  order_id     text NOT NULL,
  PRIMARY KEY (event_id, ticket_id),
  UNIQUE (event_id, seat_id)                -- a second ticket for a seat fails
);

CREATE TABLE outbox (
  event_id     text,
  outbox_id    bigserial,
  payload      jsonb NOT NULL,              -- capture, issue tickets, email
  sent_at      timestamptz,                 -- NULL until the relay is done
  PRIMARY KEY (event_id, outbox_id)
);

Four things to note.

Every primary key starts with event_id. It's the shard key, so one show's seats, orders, tickets and outbox rows sit on one shard, and each booking step is one local commit.

UNIQUE (event_id, seat_id) on tickets. The seat's status already prevents a double sale. The constraint makes a bug in that logic fail with an error instead of printing two tickets for one seat. It costs one index, and it's the last check behind requirement 1.

No count of free seats is stored. An expired hold counts as free without anybody writing to it, so a stored count would drift away from the seats. The snapshot in section 4 counts free seats once a second instead.

buyers exists to be locked. A show allows, say, 4 tickets per account. Inside the hold's transaction, the service locks the account's buyers row, then counts its tickets in confirmed orders and in live holds. Two holds from one account then run one after the other, so they can't both pass the count.

The queries that carry the product

The hold is the statement in the senior tier, or the allocation in the staff tier. Three more carry the rest:

-- The confirm, the pivot. Runs only after Stripe has said the
-- payment is requires_capture. Seats, order, tickets and the
-- outbox row that will capture the payment, in one commit.
BEGIN;
UPDATE seats SET status = 'SOLD'
WHERE event_id = 'evt_7' AND held_by = 'ord_42'
  AND status = 'HELD' AND held_until > now();      -- expect 3 rows
UPDATE orders SET status = 'CONFIRMED'
WHERE event_id = 'evt_7' AND order_id = 'ord_42' AND status = 'AUTHORISING';
INSERT INTO tickets (event_id, ticket_id, seat_id, order_id) VALUES (...), (...), (...);
INSERT INTO outbox (event_id, payload)
VALUES ('evt_7', '{"order":"ord_42","do":["capture","issue","email"]}');
COMMIT;

-- The limit: tickets this account already has for this show.
SELECT coalesce(sum(quantity), 0) FROM orders
WHERE event_id = 'evt_7' AND account_id = 'acct_9'
  AND (status IN ('CONFIRMED', 'CAPTURED')
       OR (status IN ('HOLDING', 'AUTHORISING') AND held_until > now()));

-- The snapshot, once a second, on a replica: every free seat.
SELECT seat_id FROM seats
WHERE event_id = 'evt_7'
  AND (status = 'AVAILABLE'
       OR (status = 'HELD' AND held_until < now()));

The hold runs most often during a rush, because people who don't buy still hold. The interviewer will push on the confirm, because it's where the money and the seats meet. If it updates fewer than three seats, the booking service reads the rows before doing anything else, as Distributed Transactions and Sagas sets out. Seats already SOLD to ord_42 mean an earlier try won. Anything else means the hold was lost, and the authorisation gets cancelled.

2. How does a hold become a ticket?

The booking is a saga, as in Distributed Transactions and Sagas: each step commits on its own, and a later failure runs steps that undo the earlier ones. The steps are: hold the seats, authorise the card to reserve the money, confirm the seats, then capture the money. The confirm is the pivot, the one step whose commit decides the outcome. Before it, the undo steps are releasing the hold and cancelling the authorisation, and both cost nothing. After it, every step is retried until it succeeds.

Four details are specific to this system.

The order row is the saga's state. orders.status moves from HOLDING to AUTHORISING to CONFIRMED to CAPTURED, or to CANCELLED. If a booking server crashes, the row stays where it was.

A worker looks for orders still in AUTHORISING a minute after their hold has run out. The confirm can no longer succeed for those, so the worker cancels the authorisation if Stripe has one, and marks the order CANCELLED. The orders table and this worker are all the saga needs. There is no separate orchestrator, because every step except the Stripe calls is a local commit.

Two signals arrive for one payment. Many card payments need the buyer's bank to approve them, in the bank's app or on a page the bank shows, a check called 3-D Secure. So the authorisation finishes outside the request that started it. Two things then tell the booking service it's done: the buyer's browser comes back to the checkout page, and Stripe calls the service with an event, a webhook. Either can come first, and Stripe may deliver the webhook more than once.

Neither signal is trusted on its own. The booking service accepts a webhook only if Stripe's signature on it checks out, and it finds the shard from the payment's metadata.

For either signal, it reads the order first. An order already CONFIRMED gets the same answer again, with nothing changed. Otherwise the service fetches the payment from Stripe and goes on only if its status is requires_capture, which means the money is authorised and waiting. Then it runs the confirm. If both signals race past the first check, the second confirm finds the seats SOLD with held_by = 'ord_42' and returns the same answer.

Two signals, one confirm
The buyer approves the payment in their bank's app (1). The browser returns and asks for the confirm (2). The booking service fetches the payment from Stripe, sees requires_capture, moves the seats to SOLD in one commit, in green, and answers the browser. Stripe's signed webhook arrives a moment later (3). The booking service finds ord_42 already confirmed, changes nothing, and Stripe gets the same answer.The buyer approves the payment in their bank's app (1). The browser returns and asks for the confirm (2). The booking service fetches the payment from Stripe, sees requires_capture, moves the seats to SOLD in one commit, in green, and answers the browser. Stripe's signed webhook arrives a moment later (3). The booking service finds ord_42 already confirmed, changes nothing, and Stripe gets the same answer.
Neither signal is trusted, and only the first confirm changes anything. The buyer approves the payment in their bank's app (1). The browser returns and asks for the confirm (2). The booking service fetches the payment from Stripe, sees requires_capture, moves the seats to SOLD in one commit, in green, and answers the browser. Stripe's signed webhook arrives a moment later (3). The booking service finds ord_42 already confirmed, changes nothing, and Stripe gets the same answer.

Every step carries a key. The page sends an Idempotency-Key with the hold, one per tap on the hold button, so a retried tap finds the hold it already made.

Calls to Stripe carry keys too. Stripe saves the first response for a key, errors included, and returns an error if a retry's parameters differ from the first request. So one key per order would break the moment a buyer changed card. Each authorisation attempt gets its own key: ord_42:authorise:1, then ord_42:authorise:2 if the buyer tries another card. The capture's key is ord_42:capture.

A hold can run out during the payment. The confirm checks held_until > now(). If the bank approves after the deadline, the confirm changes nothing, the booking service cancels the authorisation, and the buyer is told the hold ran out. Distributed Transactions and Sagas sizes the hold at 10 minutes, so this is rare.

The confirm's outbox row carries the capture, the tickets and the email, so a crash right after the confirm loses none of them. A relay reads the row and calls Stripe's capture with its key, retrying until Stripe accepts. The capture follows within seconds, well inside the 7 days an online card authorisation lasts. The relay then marks the order CAPTURED, issues the tickets to the app, sends the email, updates the index of orders by account, and sets sent_at.

3. The waiting room, and who gets a turn

When 330,000 people want 16,700 orders, something decides who gets a turn. If the design doesn't decide, the network does, because whoever's request reaches the database first wins. So the question here is what rule decides, and what it costs to hold everyone the rule turns away.

Naive

No line: let everyone at the sale, and add servers

It's tempting because autoscaling exists, and a line feels like giving up. Scale the booking service and the database replicas, and serve everyone.

The Eras presale shows the load, and it arrived even though Ticketmaster had a queue and access codes in place. Ticketmaster still had to slow some sales and delay others, and it estimated that about 15 percent of interactions across its site had problems.

Without a line, all 330,000 people in our stress case send holds, and at most 16,700 orders can ever succeed. The fastest requests win, which favours scripts, bots and fast connections. Adding servers makes the wasted holds arrive faster.

Senior

A waiting room: a random draw for early arrivals, then first come, released as space opens

Put a line in front of the sale. Ticketmaster opens its waiting room up to 30 minutes before a sale, and anyone who joins after the start goes to the back. Its guide says only that the time someone joins doesn't decide their place. Queue-it, which sells waiting rooms to other ticket sellers and shops, describes a draw. When the countdown reaches zero, early arrivals are randomized "like a raffle", and later ones are served in arrival order.

The random draw is the important part. If arrival time set the order, everyone would arrive in the last second before 10:00, and the fastest connection would win. With a draw, joining at 9:31 is as good as joining at 9:59, so nobody has a reason to hammer the site at 10:00:00.

The line then lets people in as fast as the sale can serve them. Ticketmaster's queue guide says "Only a few hundred people can shop at once", and its help page says "We only allow more people in when space opens up." This example uses a far larger stress case: 1,000 people let in a minute per show, each inside for about 5 minutes, so about 5,000 inside at once. Of every 10 let in, 7 buy and 3 leave, the abandonment rate Distributed Transactions and Sagas assumes.

This is the standard answer. Its cost is that the line holds everyone who wants in. 330,000 people wait, and in deep dive 6's model about 306,000 of them never get a turn. A bot that registers many accounts also gets a place in the draw for each one.

Staff

Decide most of the outcome before the sale starts

Question the premise that the on-sale decides who buys. For its biggest sales, Ticketmaster runs Verified Fan. Fans register days ahead, with the account they'll buy from, and a lottery-style process picks who gets an access code. The code works only for that account. On sale day, only those accounts can shop.

Deciding most of it before the sale
Days before the sale, fans register with the account they will use (1). The seats, and how many invited fans usually buy, set how many codes go out, and the draw picks who gets them (2). The rest go on a waiting list. On sale day, only invited accounts enter the line (3), so the line holds people who can mostly buy.Days before the sale, fans register with the account they will use (1). The seats, and how many invited fans usually buy, set how many codes go out, and the draw picks who gets them (2). The rest go on a waiting list. On sale day, only invited accounts enter the line (3), so the line holds people who can mostly buy.
The draw moves to the days before, when nobody is waiting on a page. Days before the sale, fans register with the account they will use (1). The seats, and how many invited fans usually buy, set how many codes go out, and the draw picks who gets them (2). The rest go on a waiting list. On sale day, only invited accounts enter the line (3), so the line holds people who can mostly buy.

The invitations can be sized to the seats. For the Eras Tour, Ticketmaster said 3.5 million people registered, about 1.5 million got codes, and 2 million went on a waiting list. It also said about 40 percent of invited fans usually buy, at about 3 tickets each. 1.5 million invitations × 40 percent × 3 tickets is 1.8 million tickets, close to the 2 million it sold to Verified Fans that day.

What you give up: the sale needs a registration window days ahead. The 2 million on the waiting list still hear no. They just hear it before the sale instead of during it. And the code check becomes the thing to attack, which deep dive 3 makes cheap.

How the line works

How the line works
Before the sale, a page joins once per account (1). At the start, the draw gives each early account a position, and the page gets it back as a signed ticket (2). The page then polls serving, which the CDN answers from a one second cache (3). When serving passes its position, it trades the ticket for an admission (4). The controller moves serving from the free seats and how fast people are finishing (5).Before the sale, a page joins once per account (1). At the start, the draw gives each early account a position, and the page gets it back as a signed ticket (2). The page then polls serving, which the CDN answers from a one second cache (3). When serving passes its position, it trades the ticket for an admission (4). The controller moves serving from the free seats and how fast people are finishing (5).
Each page keeps its own place, and the line shares one number. Before the sale, a page joins once per account (1). At the start, the draw gives each early account a position, and the page gets it back as a signed ticket (2). The page then polls serving, which the CDN answers from a one second cache (3). When serving passes its position, it trades the ticket for an admission (4). The controller moves serving from the free seats and how fast people are finishing (5).
  1. Join. Up to 30 minutes before the sale, a signed-in buyer opens the sale's page and joins. The line service adds the account to a set in Redis, SADD line:evt_7:early acct_9. A second join from the same account changes nothing.
  2. The draw. When the sale opens, a job reads the set, shuffles it, and writes each account's position. Accounts that join later take the next number from a counter, INCR line:evt_7:next, which starts after the last early position.
  3. The position ticket. The page asks for its position once and gets it back signed by the line service, with the show, the account and the position inside. From then on the page holds its own position, and the line service never looks it up again.
  4. One number. Every few seconds the page asks for serving, the highest position let in so far. It's one number per show, so the CDN answers it from a one second cache at each of its points of presence (PoPs). A PoP is one of the CDN's locations near users. The CDN's cache key ignores query strings, so a page can't get past the cache by adding one.
  5. Admission. When serving passes its position, the page sends its ticket to /admit. The line service makes four checks. The signature is valid, and the ticket's account is the signed-in account. The ticket's position is at or below serving as Redis holds it, and the account hasn't been let in before. The last one is SET line:evt_7:in:acct_9 1 NX, kept for the whole sale, so one ticket can't be used twice. Then it returns an admission token: signed, naming the account, and lasting 10 minutes.
  6. The controller. Every few seconds, a controller decides how far to move serving. Deep dives 4 and 6 work out the rule.

The line's data lives in Redis, not in the shards. One show's 330,000 positions are handed out in the first minute, about 5,500 reads a second. All of it is thrown away an hour after the sale.

Two choices in that list are deliberate.

The position lives in a signed ticket, not only in Redis. If Redis fails over and loses its last second of writes, nobody loses their place, because each page already holds proof of it. Redis only has to keep the positions until the pages have fetched their tickets.

Not everyone whose number comes up is still there. Some closed the tab an hour ago. So the controller counts the admissions people claim, not how far serving has moved, and moves serving further when fewer people claim their turn. A buyer who comes back to the page later still gets in, because their number has already passed. Once in, they have the token's 10 minutes, about the time Ticketmaster's help page gives a buyer once their turn comes.

Back of envelopeWhat the line costs to hold
330,000 people in one show's line. Each page checks
every 5 seconds, an assumption. Price the checks two
ways.

Each check reads that person's position
  reads        330,000 / 5 s                 = 66,000/s
  every answer is different, so no cache can help

Each check asks only for serving, one value per show
  at the CDN   330,000 / 5 s                 = 66,000/s
  at the origin, one miss per PoP a second,
  300 PoPs, assumed                          ≈    300/s
  positions handed out, once each            = 330,000 in all
  ─────────────────────────────────────────────────────
Shared, the number turns 66,000 reads a second into
about 300. Holding 330,000 people costs about as much
at the origin as one busy web page.

4. How does a buyer see which seats are free?

The seat map is two things with different lifetimes. The drawing, every section, row and seat and where it sits, belongs to the venue's layout and changes perhaps once a season. Availability, which seats are free, changes many times a second during an on-sale.

The drawing is cached forever. Its URL carries the layout's version, /maps/venue_311/v14.json, so a new layout is a new URL and nothing ever has to be removed from a cache. That's the third way to invalidate in Caching Strategies and Invalidation: change the key. The CDN serves it from its PoPs.

The line has already decided who reads availability. During an on-sale, only people inside the sale load it. The 330,000 in the line see their position, not the seats.

Back of envelopeWho reads availability, and what each read costs
During the rush, one show, at the stress case from
section 3: 1,000 people let in a minute, each inside for
about 5 minutes. Each page refreshes the map every 2 s.

  inside       1,000/min × 5 min              = 5,000 people
  reads        5,000 / 2 s                    = 2,500/s

Each read queries the seats table
  rows read    2,500 × 50,000                 = 125M rows/s

One snapshot a second, built from a replica
  rows read    50,000 × 1                     = 50,000 rows/s
  size         1 bit per seat, 50,000 / 8     ≈ 6 KB
  sent         2,500 × 6 KB                   ≈ 15 MB/s, by the CDN

If the 330,000 in the line loaded it too
  reads        330,000 / 2 s                  = 165,000/s
  ─────────────────────────────────────────────────────
A query per read costs 2,500 times the rows of one
snapshot a second. Build it once a second, and keep
the line off it.

So one process per show, the snapshot builder, runs the free-seats query once a second against a replica of the show's shard. It writes the result, a bitmap of free seats plus a count per section, to object storage such as S3 under a new version. The CDN serves the newest version with a one second cache. Each page sends the version it already has in an If-None-Match header, and gets back a 304 Not Modified with no body when nothing has changed.

Two layers, two lifetimes
The venue drawing sits behind a versioned URL on the CDN and never expires (1). Once a second, the snapshot builder reads the free seats from a replica of the show's shard (2) and writes a new snapshot (3), which the CDN serves with a one second cache. The buyer's page draws one on top of the other (4). The people in the line, in grey, load neither.The venue drawing sits behind a versioned URL on the CDN and never expires (1). Once a second, the snapshot builder reads the free seats from a replica of the show's shard (2) and writes a new snapshot (3), which the CDN serves with a one second cache. The buyer's page draws one on top of the other (4). The people in the line, in grey, load neither.
The drawing is cached forever, and availability is rebuilt once a second by one process. The venue drawing sits behind a versioned URL on the CDN and never expires (1). Once a second, the snapshot builder reads the free seats from a replica of the show's shard (2) and writes a new snapshot (3), which the CDN serves with a one second cache. The buyer's page draws one on top of the other (4). The people in the line, in grey, load neither.

One writer per show also removes two caching problems. Nothing can write an older snapshot over a newer one, the stale-set race, because only one process writes. And when the cached copy expires, 2,500 readers don't all go to the database, because readers never go to the database.

The snapshot can be up to about 4 seconds old: a second between builds, replica lag, a second in the cache, and up to 2 seconds before the page asks again. So a buyer can click a seat someone took a few seconds ago. The hold's conditional write says no, and the buyer picks again. In the rush, when the server chooses seats, the map only needs the count per section, and a stale count costs even less.

Every data store, and what forces it

data storewhat goes in itthe requirement that forces it
Postgres, 64 shards, placed by a directoryseats, holds, orders, tickets, outbox1 and 2: a conditional write per seat, and one local commit per booking step
Redis, a primary and a replicaearly joins, positions, the late counter, serving, who has been let in3: thousands of joins a second at the start, and data that lives for an hour
S3 behind the CDNvenue drawings by version, availability snapshots4: read by everyone, written rarely or once a second by one process
Postgres, keyed by accounteach account's orders across all shows"my tickets", fed by the outbox, seconds behind
Stripeauthorisations and captures2: the money is held by the card processor, not by us

Deep dives

The first three come up in most versions of this interview: sizing, hot keys, and bots.

1. How big does each part need to be?

Do this arithmetic out loud. It decides which tier needs the machines.

Back of envelopeThree tiers, sized separately
The busiest morning: 50 shows go on sale at 10:00, each
letting in 1,000 people a minute as in section 3. About
2M people wait across all their lines, an assumption.
Size each tier on its own.

The line
  joins over 30 min     2M / 1,800 s          ≈  1,100/s
    near the start, assumed 5×                ≈  5,600/s
  positions, handed out in the first minute
                        2M / 60 s             ≈ 33,000/s
  one Redis shard, ~100,000 simple ops/s      →  1 shard
  checks of serving     2M / 5 s              = 400,000/s
    at the CDN; at the origin, at most
    50 shows × 300 PoPs                       ≤ 15,000/s
  admissions            50 × 1,000 / 60 s     ≈    830/s

The map
  50 shows × 2,500/s                          = 125,000/s
    at the CDN; 50 snapshot builders, 1 query/s each

The sale, per show
  calls    17 holds + 12 pays + 2 × 12 confirms
                                              ≈     53/s
  commits  from section 1's worksheet         ≈     60/s
The sale, 50 shows
  calls    50 × 53/s                          ≈  2,650/s
  commits  50 × 60/s                          =  3,000/s
    over 64 shards                            ≈     50/s each
  ─────────────────────────────────────────────────────
The CDN answers over 500,000 requests a second. Our own
servers answer about 50,000 in the first minute, mostly
handing out positions, and under 20,000 after it. The
databases that hold the seats see 3,000 commits.

The inventory is the smallest tier. About 50 commits a second per shard is about 1 percent of one Postgres primary. The line's own servers are about ten stateless instances at the first-minute peak, at about 5,000 requests a second each, the figure the rate limiter breakdown uses for a gateway. The booking service is a handful more. The CDN carries nearly everything.

Scale on the calendar, not on load. The spike arrives at a known minute, and it arrives within seconds, faster than autoscaling reacts. So scale the line's servers up when the waiting room opens, 30 minutes before the sale. Load the venue drawing and the serving value into the CDN before anyone asks for them.

2. Hot keys and contention

An on-sale puts every write for one show on one shard. Hashing can't spread one show, because the show is the key. Two things make that safe. The line caps how many people write at once, and allocation by section, the staff answer in section 1, stops them failing on the same seat rows. One hot row is left, the count for a standing floor.

A standing floor has no seat rows, only a count, and every floor order changes it. Each floor hold also gets its own row, with an owner and a deadline, the way a seat does:

CREATE TABLE ga_pools (
  event_id    text,
  pool_id     text,                   -- 'floor'
  remaining   int  NOT NULL,
  PRIMARY KEY (event_id, pool_id)
);
CREATE TABLE ga_holds (
  event_id    text,
  order_id    text,                   -- the owner
  pool_id     text NOT NULL,
  quantity    int  NOT NULL,
  held_until  timestamptz NOT NULL,   -- the deadline
  status      text NOT NULL,          -- HELD | SOLD | RELEASED
  PRIMARY KEY (event_id, order_id)
);

-- The hold: take 3 from the count and write the hold, in one commit.
BEGIN;
UPDATE ga_pools SET remaining = remaining - 3
WHERE event_id = 'evt_7' AND pool_id = 'floor' AND remaining >= 3;  -- 1 row, or stop
INSERT INTO ga_holds VALUES
  ('evt_7', 'ord_51', 'floor', 3, now() + interval '10 minutes', 'HELD');
COMMIT;

-- The release job: mark the hold released and give its 3 back,
-- in one commit, so a hold can't be given back twice.
BEGIN;
UPDATE ga_holds SET status = 'RELEASED'
WHERE event_id = 'evt_7' AND order_id = 'ord_51'
  AND status = 'HELD' AND held_until < now();     -- 1 row, or stop here
UPDATE ga_pools SET remaining = remaining + 3
WHERE event_id = 'evt_7' AND pool_id = 'floor';
COMMIT;

ga_pools is the event's remaining-count row from Distributed Transactions and Sagas. Its worksheet puts a local commit on one row at about 3,300 a second, and the line holds the floor to tens a second. The usual fix for a key with too many writes is to split it into several rows and add them up on read. Here the row needs no splitting, and splitting it would make every read of the count cost several lookups, for load the line already removed.

One difference from seats: a count can't expire on its own the way a seat row does, so an expired floor hold needs the release job above. The confirm for a floor order moves its ga_holds row from HELD to SOLD, with the same held_until > now() check as a seat.

3. Bots and scalpers

A scalper wants seats to resell. Live Nation, which owns Ticketmaster, told the US Senate in January 2023 that the Eras presale drew three times the bot traffic it had ever seen. It said that, for the first time, bots also attacked its Verified Fan password servers. The bots got no tickets, it said, but the attack forced it to slow down and pause the sale.

A bot can do three things here: take places in the line, take seats, and hold seats it won't buy so that nobody else can have them. Every check in this design counts per account, because an account is the one thing a bot can't make for free. A bot can change its IP address on every request. Making an account that passes registration costs it far more.

  1. Registration. For the biggest sales, fans register days ahead, and a draw picks who gets a code that works for one account only. Make the code a keyed hash of the account and the show, using a secret only the line service holds. Checking a code is then a hash, not a database read, so a flood of guesses costs CPU on the line's servers and reads no database.
  2. Joining. One place per account, and a rate limit on joins per account. Sign-in and registration come before the account is known, so they sit behind the per-address and per-/24 layers from the Distributed Rate Limiter.
  3. Admission. One admission per account per show, for the whole sale, and the token names the account. Ticketmaster puts a buyer who joins from a second device at the back of the line.
  4. Holds. One live hold per account per show, plus the ticket limit, both checked inside the hold's transaction.
Back of envelopeWhat 1,000 bot accounts get
A scalper registers 1,000 accounts, and all of them join
one show's line of 330,000. About 23,700 people get a
turn before the show sells out, from deep dive 6. The
limit is 4 tickets per account, an assumption.

  chance of a turn, per account
                23,700 / 331,000              ≈ 7.2%
  bot accounts with a turn
                1,000 × 7.2%                  ≈ 72
  tickets       72 × 4                        = 288
  share of the show
                288 / 50,000                  ≈ 0.6%

Seats the bot can block by holding and leaving
  72 accounts × 4 seats, for 10 minutes each  = 288
  ─────────────────────────────────────────────────────
With a random draw and limits per account, a bot gets
its share of the accounts, not its share of the speed.
The fight moves to how many accounts it can register.

That's why registration carries most of the effort. Ticketmaster ties Verified Fan status to the account and checks it at login. Each account a bot registers then has to pass that check, and each one only buys it one more entry in the draw.

4. What happens when checkout slows down?

Halfway through an on-sale, the card processor slows down. Approvals that took 2 seconds take 30, and some time out and retry. Nothing has failed, but every buyer inside the sale now takes longer to finish. So what does the sale do with the people inside, and with the people still waiting?

Back of envelopeWhen the people inside take twice as long
Little's law again: people inside = the rate they come in
× how long each stays. In the stress case, 1,000 come in
a minute and each stays about 5 minutes. Say slow
payments double the stay to 10 minutes, an assumption.

Keep letting in 1,000 a minute
  inside         1,000/min × 10 min          = 10,000 people
  seats in their carts 10,000 × 3            = 30,000, 60% of the show
  buyers who take more than 10 minutes
  lose their hold at the confirm

Let in only as many as leave
  leaving        5,000 / 10 min              = 500/min
  inside         500/min × 10 min            =  5,000 people
  the other 500 a minute wait in the line, at one
  cached check of serving each
  ─────────────────────────────────────────────────────
Holding the admission rate fixed doubles the people
inside and puts 60 percent of the show in carts. Tying
it to the rate people leave keeps the sale at its
normal size, and the extra people wait where waiting
costs almost nothing.
Naive

Keep letting people in, and add booking servers

More servers is the reflex. But the slow part is outside, at the card processor, and more booking servers only send more calls to it at once. Inside the sale, the number of buyers doubles, as the worksheet shows. Holds run out before payments finish, buyers lose seats they were paying for, and each one tries again, which adds more calls to the slow processor. This is how a slow dependency turns into failed checkouts.

Senior

Timeouts, a circuit breaker on the payment call, and a clear error

Put a timeout and a circuit breaker on the authorisation call. A circuit breaker is a switch that stops calling the processor once calls keep failing, so the booking service fails fast instead of piling up waiting threads. Circuit Breakers, Bulkheads and Backpressure has the mechanics. The buyer gets a clear "payment unavailable, try again" while keeping the hold.

This keeps the booking service alive, and it's the standard answer. The cost is that the line keeps letting people in to a checkout that's failing. Each new buyer holds seats, meets the error, and leaves those seats in a cart for 10 minutes. The errors grow with the admission rate.

Staff

Slow the line, not the checkout

The admission rate doesn't have to be a number set before the sale. Make it follow how fast people leave the sale, by buying or by giving up. When checkout slows, fewer people leave, so fewer are let in. The sale stays at 5,000 people instead of 10,000, and the extra people wait in the line.

Ticketmaster's help page, quoted in section 3, describes its normal behaviour the same way. The controller does it every few seconds, from two inputs it already has: how many admissions were claimed, and how many orders reached CONFIRMED or CANCELLED.

What you give up: the sale takes longer, and people in the line see their position move more slowly. A controller that reacts too fast can swing between letting in too many and too few, so it changes the rate in small steps and averages over a minute.

5. How does the seat map stay current?

Inside the sale, the pages for one show send 2,500 polls a second. The CDN answers each one with a new 6 KB snapshot or a 304.

Pushing instead would cost far more. Count the changes in the rush. 1,000 holds a minute, three seats each, is 50 seats a second going to HELD. About 12 confirms a second turn 35 seats to SOLD. Releases and expiries return about 15 more. That's about 100 seat changes a second.

Pushed one by one to 5,000 people, it's 500,000 messages a second, against 2,500 polls. Pushed in a batch once a second, it's 5,000 messages a second, more than polling, plus 5,000 held connections that every deploy has to drain.

This is the dashboard case in WebSockets, SSE and Polling. A page needs the latest map, not every map in between, and polling skips the in-between versions on its own.

Outside an on-sale, the numbers are smaller and the answer is the same. An ordinary show sells a few seats a minute, so the snapshot changes rarely and its cache can live for 10 seconds or more. The page refreshes when the buyer opens it or comes back to the tab.

6. What does an abandoned hold cost?

Every hold keeps three seats off sale for up to 10 minutes. Most holds end in a purchase. Some end because the buyer closed the tab, and those seats come back only when the deadline passes.

The page releases the hold when the buyer presses cancel or leaves checkout, with DELETE /v1/events/evt_7/orders/ord_42/hold. That runs the release from Distributed Transactions and Sagas, which sets the seats back to AVAILABLE only if ord_42 still holds them. A closed tab sends nothing, so the deadline does the work.

The hold worksheet in Distributed Transactions and Sagas counts one seat per hold, and finds 3,000 seats in the carts of people who have left. Here each hold is 3 seats, so the same rates leave 9,000.

Back of envelopeSeats in carts, and when they come back
1,000 people let in a minute, 3 seats each, so holds
start on 3,000 seats a minute. 7 in 10 buy within about
5 minutes. 3 in 10 leave, and their holds run the full
10 minutes.

Seats in carts at once, by Little's law
  average time a seat sits in a cart
    0.7 × 5 min + 0.3 × 10 min               = 6.5 min
  3,000/min × 6.5 min                        = 19,500 seats
  of those, in carts of people who left
    3,000/min × 0.3 × 10 min                 =  9,000 seats

When the free seats run out
  first 10 minutes, nothing comes back
    50,000 − 3,000/min × 10 min              = 20,000 free
  then 900 a minute return, 0.3 × 3,000
    20,000 / (3,000 − 900)                   ≈ 9.5 min more
                                             ≈ minute 20
  ─────────────────────────────────────────────────────
By minute 20, every seat is sold or in a cart, with
19,500 in carts. From then on the line can only let in
people for seats that come back, 900 a minute at first,
or 300 people.
One show's seats over the first 50 minutes
Free seats, the dark line, fall to zero at minute 20 (1). Seats in carts, the orange line, level off at about 19,500. Sold seats, in green, reach about 44,500 by minute 30 (2). After minute 20, abandoned holds return seats in waves, each about 3 tenths the size of the one before, and the line lets in about 300 people a minute, then fewer, to buy them. Sales reach 49,000 by about minute 44 (3).Free seats, the dark line, fall to zero at minute 20 (1). Seats in carts, the orange line, level off at about 19,500. Sold seats, in green, reach about 44,500 by minute 30 (2). After minute 20, abandoned holds return seats in waves, each about 3 tenths the size of the one before, and the line lets in about 300 people a minute, then fewer, to buy them. Sales reach 49,000 by about minute 44 (3).
The last fifth of the seats sells in waves, as abandoned holds run out. Free seats, the dark line, fall to zero at minute 20 (1). Seats in carts, the orange line, level off at about 19,500. Sold seats, in green, reach about 44,500 by minute 30 (2). After minute 20, abandoned holds return seats in waves, each about 3 tenths the size of the one before, and the line lets in about 300 people a minute, then fewer, to buy them. Sales reach 49,000 by about minute 44 (3).

This sets the controller's second rule.

  • While free seats remain, it lets people in at the rate deep dive 4 allows.
  • When every seat is sold or in a cart, it stops. The line tells waiting buyers that the remaining seats are in carts and some may come back.
  • As holds run out, it lets in one person for every 3 seats that return.
  • When the last seat is sold and no holds remain, the line tells everyone left that the show has sold out.

In this model about 23,700 people get a turn, and the other 306,000 hear from the line, never from the database.

A shorter hold returns seats sooner and shortens the waves. But Distributed Transactions and Sagas works out that the slowest booking that should still succeed takes about 7 minutes, so a shorter hold takes seats from people who are paying. 10 minutes, with a release when the buyer leaves, is the trade.

7. Multi-region

Buyers for a show are mostly near its venue, and a show's seats need one place where holds are decided. So the seats of each show live in one region, its home region, usually the one nearest the venue. The line's Redis for that show lives there too. The data is partitioned by show across regions, not copied for writing everywhere.

Where the writes land. Every call that changes something goes to the home region. That's the join, the position fetch and the admission at the line service, and the hold, the payment and the confirm at the booking service. A buyer on another continent pays one round trip between regions, 60 to 150 milliseconds, on each of those calls. Against a one second budget for a hold, that's fine.

What every region has. The CDN answers serving, the venue drawing and the availability snapshot near every buyer, so the waiting crowd never crosses a region. Each shard's primary has a standby in another zone of the same region, which receives every commit before it's acknowledged, so a failover loses no confirmed sale. A second copy in another region receives commits a moment after they're acknowledged, for disaster recovery.

What it costs. If a whole region goes down, the shows whose home is there stop selling until the copy in another region is promoted. That copy can be a few seconds behind, so a confirm that committed just before the outage may be missing. Stripe may still hold its capture, and the app its tickets.

So before the promoted region reopens holds for those shows, a job compares Stripe's records with the promoted copy. For a capture with no confirmed order, it applies the confirm again if the seats are still free. If they aren't, it refunds the capture and voids the tickets the relay had already issued.

Where a show's seats live
evt_7 plays in Atlanta, so its seats live in us-east (1), with a standby in a second zone. A buyer in Europe checks serving and loads the map from a nearby PoP (2). The calls that change something, the join, the position fetch, the admission, the hold, the payment and the confirm, cross to us-east (3), about 100 ms a round trip each. A copy in another region receives commits a moment later, for disaster recovery (4).evt_7 plays in Atlanta, so its seats live in us-east (1), with a standby in a second zone. A buyer in Europe checks serving and loads the map from a nearby PoP (2). The calls that change something, the join, the position fetch, the admission, the hold, the payment and the confirm, cross to us-east (3), about 100 ms a round trip each. A copy in another region receives commits a moment later, for disaster recovery (4).
A show's seats have one home, and the crowd is served everywhere. evt_7 plays in Atlanta, so its seats live in us-east (1), with a standby in a second zone. A buyer in Europe checks serving and loads the map from a nearby PoP (2). The calls that change something, the join, the position fetch, the admission, the hold, the payment and the confirm, cross to us-east (3), about 100 ms a round trip each. A copy in another region receives commits a moment later, for disaster recovery (4).

8. How do you know it is working?

During an on-sale, four questions need answers within seconds.

  • Is the line moving? People waiting, the admission rate, and admissions claimed against positions passed.
  • Are holds succeeding? Holds attempted and held, by section. A falling success rate in seat-choice mode means buyers are fighting over the same seats.
  • Is checkout finishing? Time from hold to confirm, the share of holds that end confirmed, and the card processor's latency and error rate. These feed the controller as well as the dashboard.
  • Where are the seats? Free, in carts and sold, from the snapshot, against the number of people still in the line.

Watch the bot signals too: joins per network block, accounts per device, and codes tried per account.

Label every metric by show and section, never by account. Per-account detail belongs in sampled logs. An account label on 330,000 waiting people creates 330,000 series in the metrics backend during the busiest minute of the year.


Final design

The final design, with the path of one buyer
Blue is the buyer, grey the edge and telemetry, purple the line and the booking service, orange the data they keep, teal Stripe, the outbox relay and the snapshot builders, and yellow the control plane. Steps 1 to 8 match the list below. The crowd in the line touches only the CDN and the line service. Only admitted buyers' holds pass through the edge to the booking service and the shards.Blue is the buyer, grey the edge and telemetry, purple the line and the booking service, orange the data they keep, teal Stripe, the outbox relay and the snapshot builders, and yellow the control plane. Steps 1 to 8 match the list below. The crowd in the line touches only the CDN and the line service. Only admitted buyers' holds pass through the edge to the booking service and the shards.
The badges follow the eight steps below. Blue is the buyer, grey the edge and telemetry, purple the line and the booking service, orange the data they keep, teal Stripe, the outbox relay and the snapshot builders, and yellow the control plane. Steps 1 to 8 match the list below. The crowd in the line touches only the CDN and the line service. Only admitted buyers' holds pass through the edge to the booking service and the shards.

One buyer, end to end:

  1. Before 10:00, the buyer signs in and joins the show's line. The line service records the account once, in Redis.
  2. At 10:00 the draw gives every early account a random position. The buyer's page fetches its signed position ticket, then checks serving on the CDN every few seconds.
  3. When serving passes the position, the line service checks the ticket's signature, its account and its position, and lets the account in once. The page gets a signed admission token that lasts 10 minutes. The controller moves serving from the free seats and the rate people leave the sale.
  4. The page loads the venue drawing and the availability snapshot from the CDN. The snapshot builder rebuilds the snapshot once a second from a replica of the show's shard.
  5. The buyer asks for 3 seats in section 112, and the call passes through the edge to the booking service. The booking service checks the admission, finds the show's shard in the directory, and one transaction locks the section, takes the best block of free seats, and holds it for ord_42 for 10 minutes.
  6. The buyer pays. The booking service, which now checks only that the buyer owns ord_42, authorises the card with Stripe under the key ord_42:authorise:1, without capturing.
  7. When the browser returns or Stripe's signed webhook arrives, the booking service fetches the payment and sees requires_capture. The confirm then marks the seats SOLD and the order CONFIRMED, and writes the tickets and an outbox row, in one commit.
  8. The outbox relay captures the payment and marks the order CAPTURED, issues the tickets to the app, sends the email, and updates the index of orders by account. Every tier reports to telemetry, labelled by show, never by account.

These numbers justify the shape. One show in the rush makes about 60 commits a second, so the busiest morning is about 3,000 across 64 shards, about 50 each. The line costs the origin about 300 requests a second, because every page polls one cached serving number. The seat map is one 6 KB snapshot a second per show, read from the CDN.


What is expected at each level

How interviewers turn what they see into these levels is in How a System Design Interview Is Scored.

Mid-level

Breadth matters more than depth at this level, and it's fine to be led.

You should land a working design. That means a hold that keeps seats for a few minutes and can't sell one seat twice, and a payment that only completes once the seats are confirmed. It also means a seat map that isn't read from the database on every view. You should be able to explain why a check followed by a separate write lets two buyers take the same seat.

You aren't expected to raise the waiting room, bots or multi-region on your own. When the interviewer says "a million people arrive at 10:00", you should get to a line that lets people in at a set rate.

The mistake to avoid is spending the interview on the event search page and the schema for venues. If you're 20 minutes in and nobody has held a seat, you've answered a different question.

Senior

You drive the structure, and three things should come up without prompting.

The hold as data. A status, an owner and a deadline in the seat row, written with one conditional statement, and an expired hold read as free. A lock held across the payment, or a hold with no deadline, fails this part of the interview.

The order of the booking steps. Authorise, confirm the seats, then capture. Say which step is the pivot, and key every step. Check the payment with Stripe before the confirm, and say what happens when the bank approves after the hold has run out.

A line in front of the sale, with a rule. A random draw for early arrivals, first come after, and a release rate. Add a seat map served from a snapshot, not from the database.

Disqualifying: charging the card before the seats are confirmed, "strongly consistent" said about the whole system, and a seat map that queries the seats table on every view.

Staff+

A correct design is still the bar. A staff answer also works out which parts don't need to exist.

Do the arithmetic that makes the inventory small. That's 14 tickets a second for a stadium that sells out in an hour, 28 orders a second in a 10 minute sellout, and a crowd many times the seats. Then use it to cut: no separate lock data store, no sharded counters, no live push of every seat change.

Treat the line as the design. It needs a rule a fan can be told, positions in signed tickets, and one cached number for everyone. Its admission rate follows the free seats and how fast people leave. When checkout slows, slow the line.

Remove contention instead of handling it. In the rush, let the server choose the seats by section, so no two buyers fail on the same seat.

Move the contest before the sale. Size invitations to the seats, and count everything per account, because accounts are what a bot can't make for free.

Shard for failure, not for speed, and place the big shows deliberately, because their dates are on the calendar.

Be able to say what you would not build. A distributed lock service for seats. Redis as the source of truth for holds. A WebSocket that pushes every seat change to everyone. A counter split across rows for a single show. Holds accepted in two regions for one show's reserved seats. A line ordered by arrival to the millisecond. Autoscaling as the plan for a sale whose start time is known weeks ahead. Each could take a team a quarter, and naming them as deliberate omissions says more than another box on the diagram.


Sources

The figures about Ticketmaster, Live Nation, Queue-it and Stripe come from the documents below. The rest, the stress case, the sizing, the line's cost and the hold model, is worked out on the page with its assumptions stated.

  • Ticketmaster, Taylor Swift | The Eras Tour Onsale Explained, November 2022. 3.5 million registrations, about 1.5 million codes and 2 million on a waiting list, and 2.4 million tickets sold in the presales. 3.5 billion requests, from bots and fans without codes, and a traffic estimate of over 900 stadium shows. About 40 percent of invited fans buying about 3 tickets each, and about an hour to sell a stadium show. About 15 percent of interactions with problems, and sales slowed and delayed.
  • Joe Berchtold of Live Nation, testimony to the US Senate Judiciary Committee, 24 January 2023, with the prepared text as quoted by Hypebot. Three times the bot traffic Ticketmaster had seen before, and the first attack on its Verified Fan password servers. No tickets taken by bots, and sales slowed and paused.
  • Ticketmaster on its waiting room and Verified Fan: How A Ticketmaster Queue Works, its guide to Smart Queue, its help page on the queue and a Verified Fan sale guide. A place is assigned when the sale starts, whatever the join time, and late arrivals and second devices go to the back. A few hundred people shop at once, more are let in only as space opens up, and a turn lasts about 10 minutes. Codes work for one account only.
  • Queue-it, How does Queue-it work. Early arrivals randomized like a raffle at the start, first in first out after it, and an outflow set in visitors per minute.
  • Stripe, Place a hold on a payment method, Idempotent requests and webhooks. Separate authorisation and capture, requires_capture, and a 7 day authorisation for online card payments. Saved responses and a parameter check for each key, kept at least 24 hours. Signed webhooks that may arrive more than once.
  • Live Nation, full year 2023 results. Over 620 million tickets in 2023.

Spot a mistake, or something unclear? . Or get in touch.

Article

Send feedback

Thank you for helping. We read every report and fix what is wrong.

How do you feel about oneby7?

Sign in to oneby7

Keep your progress, your streak and your code, on any device.

New here? This creates your account too.