← Lessons

quiz vs the machine

Platinum1850

System Design

Distributed Inventory Consistency

Keeping one stock count correct across regions, warehouses, and caches.

6 min read · advanced · beat Platinum to climb

One number, many copies

When inventory is read and written across multiple regions, warehouses, and caches, keeping the count correct becomes a distributed consistency problem. The same product may be sold concurrently from many places.

Strong versus eventual

  • Strong consistency on the decrement, via a single authoritative store or a consensus protocol, guarantees no oversell but adds latency and a single coordination point.
  • Eventual consistency lets regions act independently and reconcile later, which is fast but risks temporary oversell.

The decrement that commits a sale usually demands strong consistency; the count shown while browsing can be eventual.

Practical patterns

  • Partition stock by warehouse so each location owns its own count and decrements locally without global coordination.
  • Allocate quotas to regions for a flash sale, so each region sells from its slice independently.
  • Reconcile continuously to detect and correct drift between the source of truth and caches.

Key idea

Make the selling decrement strongly consistent while partitioning or quota allocating stock so regions act locally and reconcile drift.

Check yourself

Answer to earn rating on the learn ladder.

1. Which operation usually demands strong consistency?

2. How does partitioning stock by warehouse help?

3. Why reconcile continuously?