« All posts

Shopify Ditched Redis for MySQL in Inventory Reservations at Scale

Shopify moved its checkout inventory reservation system from Redis to MySQL, using SKIP LOCKED, composite keys and isolation tuning to scale through Black Friday peak traffic.

Shopify's checkout system long relied on Redis to reserve inventory during payment processing, but keeping reservations separate from the inventory ledger meant claim operations couldn't be atomic—risking both overselling and false stockouts. As part of a unified database strategy, the team tested whether MySQL could match Redis's throughput for this critical path.

The fix replaced a single quantity-column row per item with one row per sellable unit, using MySQL 8's SKIP LOCKED to let transactions skip contended rows instead of waiting. To keep this scalable, a bounded pool of 1,000 rows per item/location absorbs bursts, with inline replenishment guarded by a lock so concurrent reserves queue safely instead of racing.

Three engineering decisions proved essential: switching from an auto-increment key to a composite primary key cut lock counts per row in half; moving from MySQL's default REPEATABLE READ to READ COMMITTED avoided gap locks that blocked replenishment on empty tables; and standardizing table access order between reserve and claim operations eliminated deadlocks. The result is a single ACID-compliant MySQL system that handled Black Friday 2025 peak traffic without Redis's operational overhead or atomicity gaps.

» SourceHashnode #2