Data consistency at scale

Concurrency, locking, reservations, caching and sharding tasks from real high-traffic systems.

  1. Versioned Store with Optimistic Locking Stop silent overwrites between editors: every update must name the version it was based on. Easy All 5 languages
  2. Flash-Sale Reservations Without Overselling Hold stock for 10 minutes, enforce a per-customer limit, survive client retries and never oversell. Medium All 5 languages
  3. Find Deadlocked Transactions Given who-waits-for-whom edges from a lock monitor, report the transactions stuck in a deadlock cycle. Medium All 5 languages
  4. Row Lock Manager with Deadlock Detection Build the core of a database lock manager: grant, queue, release in FIFO order, and abort on deadlock. Hard All 5 languages
  5. Read-Your-Writes Replica Router Send reads to a replica only when it already has the user's latest write — otherwise use the primary. Easy All 5 languages
  6. Sharded Counter for a Hot Row Spread increments of a viral post's like counter over several slots and measure the lock waits. Medium All 5 languages
  7. Consistent Hash Ring for Shard Routing Route keys to shards on a hash ring with virtual nodes, so adding a shard only moves a slice of keys. Medium All 5 languages
  8. Single-Flight Cache Loader When a hot key expires, let one request load it while everyone else waits — instead of a thundering herd. Medium All 5 languages
  9. Cache with Version-Checked Sets Prevent the cache-aside stale-set race: a slow reader must not re-cache an old value after an invalidation. Medium All 5 languages
  10. Write-Behind View Counter with Safe Flushes Buffer view counts and flush them in batches that survive crashes and are never applied twice. Medium All 5 languages
  11. Two Checkouts, One Item Left Predict what a read-modify-write checkout does when two requests interleave. Easy Python
  12. The Stale Cache Set A slow cache-aside reader and a writer race. What ends up in the cache? Medium Node.js
  13. Read Committed vs Repeatable Read A report reads a balance twice while a deposit commits in between. What does each isolation level see? Medium Python

← All coding problems