Back to explorer
System Architectures 5 Min

Online Auction

MEDIUM

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.

code
Client Bid ---> WebSocket Server ---> Bid Worker ---> Redis Cache (Acquires Lock)
                                                          |
                                                    PostgreSQL Ledger

Components

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