u/Few_Ad6794

🔥 Hot ▲ 73 r/softwarearchitecture

System Design: Designing an online auction at 50K bids/sec

Online auctions look simple until correctness problems appear.

Two users click "Bid $105" at the same moment when the current price is $100. Both pass the "$105 > $100" check. But both cannot be accepted.

The post covers the areas that needed the most thought:

  • Per-auction serialization using Valkey single-threaded Lua, instead of row locks that can queue under load on a busy auction.
  • Effectively-once settlement using a fencing token and a stable idempotency key at the payment provider. One common mistake is putting the token inside the idempotency key, which can cause duplicate charges during retries.
  • Anti-sniping built into the same atomic script that accepts the bid, because handling it separately creates the race again.
  • Proxy bidding with a jump-to-price algorithm, so two competing auto-bidders can resolve in one write instead of many small increments.
  • WebSocket fan-out for 1M concurrent watchers using Valkey sharded pub/sub, with presence cleanup and sequence-number resume after reconnect.

It also covers the simpler Postgres-only version, which works well up to roughly 500 bids/sec. Many systems may never need the larger scaled-out design.

Link: https://crackingwalnuts.com/post/online-auction-system-design

reddit.com
u/Few_Ad6794 — 4 days ago