HomeAlgorithms & AIFlash-Sale Inventory Race Condition

Flash-Sale Inventory Race Condition

Interactive 3D simulator of mobile-checkout overselling: watch concurrent buy requests race a shared stock counter under no locking, optimistic concurrency (CAS) and pessimistic locking, and see which one actually prevents overselling.

Algorithms & AI3DModerate60 FPS📱 Mobile-adapted⇄ 2D version
mobile-ecommerce-implementation ↗ Open standalone

Mobile e-commerce checkout is a textbook concurrency problem: many devices read the same stock count, wait through a network-plus-database round trip, then write a decision. This simulator renders that race in 3D — a central inventory silo drains as glowing request tokens fly in from every direction, resolving green (sold) or red (rejected) depending on the concurrency-control strategy you pick. Switch between no locking, optimistic concurrency (compare-and-swap on a version number) and pessimistic locking (a strict FIFO queue) while tuning starting stock, checkout rate and round-trip latency, and watch live readouts for stock remaining, units oversold, rejection rate, throughput and queue depth.

⚙ Under the hood

Watch concurrent mobile checkout requests race a shared stock counter in 3D: compare no locking, optimistic concurrency (CAS) and pessimistic locking, and see live which strategy actually stops a flash sale from overselling.

concurrencyrace-conditione-commercecheckoutdistributed-systemsalgorithms

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)