Online auction
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Design an online auction (eBay): the 60-second story

    Design an online auction

    A signed bat. Seven days. Then 2,000 bids in its final second.

    200,000 people watch. Every bid needs one place in one order, before or after the end.

    Two bids at once

    Bad: Read, decide, write

    Both read Asha’s $50 and write “I lead at $51”. Ben’s $55 vanishes.

    Good: Lock the row

    Bids queue on the lock: Ben at $51, then Chen at $56.

    Asha’s max is $50, Chen’s $60. What does Chen pay?

    Robots raising one step at a time trade about 36 bids. Skip the duel: the runner-up’s maximum plus one increment.

    2,000

    bids on one item in its final second

    A locked row serves about 500 a second. The last two seconds bring 2,800; the 1,800 left over need 3.6 s more, past the end.

    One owner per auction, deciding in memory

    Bids queue in arrival order. Every 5 ms the owner writes a batch to a log kept on three machines, then answers. About 10 ms, not 3.6 s.

    “Ends at 20:00:00.” A bid tapped at 19:59:59.990 is still in flight. Does it count?

    The trick

    The owner writes CLOSE into the same log as the bids. Arrived before it? Counts. After? “Ended”.

    200,000 watchers. Do they need 2,000 prices a second?

    Publish only the latest state, at most twice a second. 400 million messages a second become 400,000, and outbid bidders still hear at once.

    After the hammer falls

    1. Create one order per auction
    2. Take payment, or autopay after 24 hours
    3. Pay the seller once money is captured
    4. Unpaid? A second-chance offer to an underbidder

    Remember

    One writer, one ordered log per auction: every bid, and the close, takes a place in it. Watchers get the latest price only.