Problem Statement
Design an online auction platform where users can:
- Create auctions with a start time, end time, and minimum bid
- Place bids on active auctions
- View a near real-time leaderboard of top bids
- Determine the winning bid when the auction closes
The system should handle high concurrency (thousands of bids per second on popular auctions).
Requirements
Functional:
- Create auction (with start/end time, min bid, item details)
- Place a bid (must be higher than current highest)
- View current top bids / leaderboard
- Determine winner at auction close
- Notify winner and seller
Non-Functional:
- Low latency bid placement (< 100ms)
- Consistent — no two users should "win" simultaneously
- Support 10K+ concurrent bidders on a single auction
- Near real-time leaderboard updates
What the Interviewer Expects
- Database schema — auctions table, bids table, users table. Discuss indexing on (auction_id, amount) for fast lookups.
- Bid placement flow — validate bid > current max, insert atomically. Discuss race conditions.
- Caching layer — Redis sorted sets for real-time leaderboard. Current highest bid cached for fast validation.
- Consistency vs speed trade-off — Redis for reads (fast leaderboard), DB as source of truth for the final winner.
- Auction close logic — scheduled job or event-driven. How to atomically determine winner.
Follow-ups
- How do you handle bid edits? (Allow multiple bids vs edit-in-place — trade-offs)
- How would you support a near real-time leaderboard? (Redis sorted sets with ZADD)
- How do you identify the winning bid reliably? (Can't rely solely on Redis — need DB confirmation with locking)
- What happens if the auction close event fails? (Idempotency, retry logic)
- How would you prevent shill bidding (fake bids to drive up price)?