---
title: "We replaced Redis with MySQL for inventory reservations—and it scaled"
description: "Shopify moved checkout inventory reservations from Redis to MySQL by modeling one row per sellable unit and using SELECT ..."
url: "https://swe.quest/articles/we-replaced-redis-with-mysql-for-inventory-reservations-and-it-scaled-2f8fab4ab3565f02"
canonical: "https://shopify.engineering/scaling-inventory-reservations"
source: "Shopify Engineering"
published: "2026-05-12"
difficulty: "medium"
kind: "Case study"
reading_minutes: 10
tags: ["mysql","ecommerce","concurrency","scalability","performance"]
---

# We replaced Redis with MySQL for inventory reservations—and it scaled

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2026-05-12, 10 min read, Case study. Original: [https://shopify.engineering/scaling-inventory-reservations](https://shopify.engineering/scaling-inventory-reservations)

## Summary

Shopify moved checkout inventory reservations from Redis to MySQL by modeling one row per sellable unit and using SELECT ... FOR UPDATE SKIP LOCKED, so concurrent checkouts grab different rows without contention while reservations and the inventory ledger share ACID transactions. Key fixes included a bounded pool of 1,000 rows per item/location with locked inline replenishment, a composite primary key that halved row locks, READ COMMITTED to avoid gap/supremum locks, consistent lock ordering to prevent deadlocks, and UNION ALL batching. The real throughput ceiling turned out to be database connection exhaustion from other checkout code, found by tagging SQL with caller comments and measuring hold time in ProxySQL; cleanup cut 50% of reads and 33% of transactions, and raising InnoDB thread concurrency removed the limit. Cutover used dual-write shadow mode with a kill switch and gradual pod-by-pod rollout.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [MySQL](https://swe.quest/tags/mysql.md) (Data & databases)
- [E-commerce](https://swe.quest/tags/ecommerce.md) (Domains)
- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [Scaling](https://swe.quest/tags/scalability.md) (Distributed systems)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- MySQL InnoDB row locking ([easy posts on MySQL](https://swe.quest/tags/mysql.md?difficulty=easy))
- transaction isolation levels ([easy posts on Consistency models](https://swe.quest/tags/consistency.md?difficulty=easy))
- connection pooling

## Keywords

MySQL, SKIP LOCKED, InnoDB, Redis, ProxySQL, Black Friday

## Related posts

- [Mitigating Deadlocks in high concurrency environments](https://swe.quest/articles/mitigating-deadlocks-in-high-concurrency-environments-f958e9ca77901412.md): Shopify Engineering · 2024-08-14 · Medium · 3 min read · MySQL, Concurrency, Storage engines, Databases
  Concurrent batch upserts into an InnoDB table keyed by a sequential id can deadlock even when processes touch different rows, because the gap locks taken on unique-key collisions span neighbouring index entries that other processes also need.
- [Shard Balancing: Moving Shops Confidently with Zero-Downtime at Terabyte-scale](https://swe.quest/articles/shard-balancing-moving-shops-confidently-with-zero-downtime-at-terabyte-scale-76a6177fa357eea4.md): Shopify Engineering · 2021-09-24 · Medium · 13 min read · MySQL, Distributed databases, Schema migrations, Scaling
  Shopify rebalances its MySQL shards by moving individual shops between pods online, with downtime confined to a brief cutover.
- [Beyond synthetic testing: Capturing and replaying real database workloads at Airbnb](https://swe.quest/articles/beyond-synthetic-testing-capturing-and-replaying-real-database-workloads-at-ad8d4a3a0c1cef6e.md): Airbnb Engineering · 2026-10-06 · Medium · 11 min read · MySQL, Testing, Capacity planning, Performance engineering, Databases
  Airbnb replaced fragmented per-language client-side query logging with a client-agnostic capture point in ProxySQL, so real production MySQL traffic can be replayed offline.
- [Rediscovering Transaction Processing From History and First Principles](https://swe.quest/articles/rediscovering-transaction-processing-from-history-and-first-principles-7a5a2c6c3ea0ae42.md): TigerBeetle · 2024-07-23 · Easy · 9 min read · Databases, Consistency models, Payments & fintech, Performance engineering, System design
  General-purpose OLTP databases hit a hard throughput ceiling on debit/credit workloads because row locks are held across multiple network round-trips, and hot rows such as a few internal accounts serialize nearly every transaction.
- [Making Shopify’s Flagship App 20% Faster in 6 Weeks Using a Novel Caching Solution](https://swe.quest/articles/making-shopify-s-flagship-app-20-faster-in-6-weeks-using-a-novel-caching-100f1c4cb3fa31e6.md): Shopify Engineering · 2021-09-22 · Medium · 8 min read · Caching, Ruby, Scaling, Deployment, Performance engineering
  Shop's home feed, which aggregated orders and carrier tracking data and accounted for 30% of database load, was moved behind a custom write-through cache in Memcached, cutting database load by 15%, overall GraphQL latency by about 20% and CPU usage by a double-digit percentage.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
