AlgoViz

Design Ticketmaster

hard 55 min

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

How to approach it

What this question tests, where it gets hard, and how to spend the time.

Read the question

What this problem tests

  • Can you split it?

    A crowd at the door, and one seat with two buyers.

  • Can you prove no oversell?

    Show the statement that decides.

  • Can you handle money?

    Unknown answers, retries, refunds.

  • Can you shape load?

    Admission instead of more servers.

Think

Five questions before you draw

Ask yourselfHere
Who does what?Fans look, wait, hold and pay; organisers publish events
What must never go wrong?One seat sold twice, or money without a seat
What is the hardest thing?A payment that takes minutes while others want the seat
What breaks first as it grows?Reads of popular pages, then the first minute of a sale
What am I giving up?People wait outside, and the map is a little old

The interview, in order

Spend the 45 minutes

MinutesDoLeave with
0 to 5Browse, hold, buy; one huge saleTargets and a hold time
5 to 10Normal day and sale minute280 to 1, 83 holds a second
10 to 15Hold and checkout requests, seat statesavailable, held, paying, sold
15 to 25Version 1, then holds, caches, roomA working purchase
25 to 40Seat contention, then waiting roomA statement and a public number
40 to 45Payment timeout, recapA clear last sentence

Lines you can open with

  1. 1

    Start

    "There are two problems here: a crowd and a seat. I will make the seat correct first, then protect it from the crowd."

  2. 2

    Park something

    "Search is a known shape. I will draw the box and come back if you want."

  3. 3

    When stuck

    "Which row decides, and what state must it be in?"

  4. 4

    Close

    "A steady door, one conditional update, authorise then sell then capture."

Do

  • Draw the seat's states
  • Count what is left after admission
  • Say what happens on a timeout
  • Keep the map a hint

Traps

  • A distributed lock before any number
  • Charging inside a database transaction
  • Autoscaling as the answer to 14 million
  • Random places for latecomers