Online Auction
Design an Online Auction System (eBay)
An online auction system handles real-time item bids and auction closing events under strict consistency.
1. High-Level Design
Bidding requires millisecond-level updates and transaction consistency to ensure late bids are rejected once the auction timer hits zero.
Client Bid ---> WebSocket Server ---> Bid Worker ---> Redis Cache (Acquires Lock)
|
PostgreSQL LedgerComponents
1. WebSocket Handler: Maintains persistent connections to broadcast bid updates to all bidders instantly.
2. Bid Validator: Validates incoming bids (must be higher than the current highest bid + increment, and sent before the auction end time).
3. Locking Service: Uses Redis Redlock to coordinate bids.
4. Database Broker: Persists winning bids to a transactional DB.
2. Potential Deep Dives
- Handling Last-Second Bids:
Use Redis Lua scripting to execute bid validation and insertion atomically. Lua scripts block subsequent evaluations until the current script completes.
- Distributed Cron for Auction Ends:
Use a job scheduler (e.g., Redis Streams or dynamic Quartz jobs) to trigger the auction closing sequence exactly when the timer expires.
3. References & Tech Blogs
Related Topics
Expand your knowledge by learning about adjacent concepts in system design.
Design a URL Shortener (TinyURL)
Build a high-throughput shortener analyzing base58 encodings and database sharding.
Networking Essentials
Learn the important parts of networking that you'll need to know for your system design interviews
API Design
Learn about API design for system design interviews
Cheat Sheet Utility
View and print a concise system design reference card.