Design an Online Auction
Understanding the Problem
🔨 What is an online auction? An online auction lists an item for a fixed period, and buyers place increasing bids until the clock runs out. When it ends, the highest bidder wins and pays their bid (or, on eBay, a price set by the second-highest bid). The hard parts are agreeing on a single highest bid when many people bid at once, and showing every watcher the new price in real time.
You may hear this as "design eBay," "design a bidding system" or "design an auction service that always shows a consistent highest bid." They are the same problem. eBay adds proxy bidding, where you enter the most you're willing to pay and the system bids for you, so we'll treat that as a deep dive.
Functional Requirements
Auction sites have a lot of surrounding product: search, seller ratings, shipping, disputes. Agree with your interviewer up front that we're designing the auction itself.
Core Requirements
- Users should be able to create an auction for an item, with a starting price and an end time.
- Users should be able to view an auction and see the current highest bid, updated in real time.
- Users should be able to place a bid, which is accepted only if it's higher than the current highest bid.
- When an auction ends, the highest bidder should win and both the winner and the seller should be notified.
Below the line (out of scope)
- Search and browsing of listings.
- Payment, shipping and disputes after the auction.
- Reserve prices, "Buy It Now" and other listing formats (we'll mention reserve prices briefly).
Non-Functional Requirements
Ask your interviewer about scale and what "consistent" means to them. For our design: 10 million auctions are live at any time, about 1 million new ones are created per day, and users place about 100 million bids per day.
Core Requirements
- The system must agree on a single highest bid for each auction. Two users must never both be told they're winning, and an accepted bid must never be overwritten by a lower one.
- The system must never lose an accepted bid. A user who sees "you're the high bidder" has a promise we need to keep.
- Watchers should see a new highest bid within about one second.
- The system should handle hot auctions: thousands of bids and 100k+ watchers on a single item in its last minutes.
- Auctions should close on time, and late bids should be rejected consistently.
Below the line (out of scope)
- Multi-region active-active bidding. Each auction is owned by one region.
- Fraud and shill-bidding detection (we'll mention where it plugs in).
The arithmetic is worth doing because it moves the hard part of the problem. 100M bids per day is about 1,200 bids per second on average, maybe 10-15k per second at peak. That's a normal write load for a sharded database. More important, the load is spread across 10M independent auctions. A single auction rarely sees more than a few dozen bids per second, even in a bidding war, and one database row can take on the order of a thousand conditional updates per second.
The read side is very different. A hot auction with 100k watchers receiving every one of 20 bids per second is 2 million messages per second out of the system, for one item.
The insight to say out loud: writes are naturally sharded by auction, so per-auction contention is real but small. The interesting problems are correctness under concurrency (two bids racing for the top spot) and read fan-out (many watchers per bid), not raw write throughput.