Shopify replaced Redis with MySQL for inventory reservations–and it scaled(shopify.engineering)
330 points by adletbalzhanov 13 days ago | 246 comments
tl;dr: Shopify migrated inventory reservations from Redis to MySQL by using MySQL 8's SKIP LOCKED feature with one row per sellable unit (capped at 1,000 per item/location), enabling ACID guarantees across reservations and the inventory ledger. Key optimizations included composite primary keys to reduce lock counts, READ COMMITTED isolation to avoid gap locks, and consistent lock ordering to prevent deadlocks. The real bottleneck turned out to be database connection exhaustion from unrelated checkout code holding connections too long—fixing that (plus revisiting InnoDB thread concurrency) removed the ceiling and let the system handle Black Friday 2025's record traffic.
HN Discussion:
  • Proposes simpler alternative designs like deducting inventory upfront with a separate in-progress row
  • Questions the 1000-rows-per-SKU design as inelegant, suggesting one row per cart instead
  • Doubts moving from Redis back to MySQL is the right choice given concurrency differences
  • Appreciates the real-world engineering story and key lesson about hidden bottlenecks
  • Criticizes the article's writing quality and internal inconsistencies