
Shopify Replaced Redis With MySQL for Inventory Reservations, and It Scaled
Shopify moved its oversell protection from Redis to MySQL, rebuilding reservations around MySQL 8's SKIP LOCKED and one row per inventory unit. The harder lesson: the bottleneck was connection usage elsewhere in checkout.
Shopify has replaced the Redis-based system that prevents overselling with a design built on MySQL 8's SKIP LOCKED feature, and says it hit its high-throughput targets during the 2025 peak traffic period.
Why the old design broke down
Oversell protection has two operations: reserve, a short hold placed when payment starts, and claim, which permanently deducts the unit from the inventory ledger when payment succeeds. Shopify's previous system kept reservations in Redis, where reserving meant decrementing a key and releasing meant incrementing it. Redis handled concurrency well, but reservations and the ledger lived in separate systems, so the claim step had to update MySQL and clean up Redis without the two actions sharing a single atomic step. Depending on the order, that could cause overselling or underselling, and the model had no awareness of multi-location inventory.
One row per unit, in a bounded pool
The new design stores one row per sellable unit instead of one row per item with a quantity column, so an item with ten units has ten rows, and reservations can share ACID transactions with the ledger. The team keeps a bounded pool of available rows, capped at 1,000 per item-location pair and refilled from the ledger by a replenishment process. If a flash sale drains the pool, replenishment runs inline behind a lock, so concurrent reserves wait instead of all racing to insert rows.
Tuning locks and finding the real limit
Several details mattered. A composite primary key on the columns used for filtering cut row locking from two locks to one per reservation. Switching the reservation transactions to the READ COMMITTED isolation level avoided the gap locks, that were blocking replenishment. Standardising lock ordering removed deadlocks between reserve and claim, and UNION ALL batching cut round trips for carts with several line items.
The expected bottleneck never appeared. With CPU far from saturated and queries already optimised, the team still hit a ceiling: connections were being exhausted by other parts of the checkout path. Tagging every SQL statement with the business process that issued it and aggregating connection hold times at the ProxySQL layer showed which callers consumed the most connection time. Cleaning up the checkout path removed 50% of reads and 33% of transactions on the primary database, and revisiting an old InnoDB thread concurrency setting removed another limit.
Cutover and results
Redis and MySQL ran in parallel in "shadow mode" with Redis remaining the source of truth, after which Shopify switched the source of truth to MySQL, keeping a kill switch and rolling out pod by pod. On Black Friday 2025, merchants on the platform hit a record $5.1 million in sales per minute at peak.
SiTech — AI-powered web development
We build fast, modern websites and bring AI into real business workflows. Have a project or a question? We'd love to help.