One row for every sellable unit, and each checkout takes any free one
One row for every sellable unit, and each checkout takes any free one.
A thousand buyers grab the last one in stock in the same second. The store has to sell that unit once and only once. Shopify rebuilt that guarantee on the ordinary database that already held its records.
Finishing a sale needed two writes that could not be made one step
Finishing a sale needed two writes that could not be made one step.
one running count per item
Shopify says its stores hit five point one million dollars a minute at the Black Friday peak. The old design kept the count of what was left in Redis, a separate high-speed system, apart from the store’s records. When those two drifted apart, a buyer could pay for stock already gone.
Ten units in stock is now ten rows
Ten units in stock is now ten rows.
So Shopify moved the hold on your stock into that ordinary database. Instead of one count per item, every sellable unit gets its own row, its own line in the list.
Thousands of checkouts reserve at the same time, because each takes a different free row
Thousands of checkouts reserve at the same time, because each takes a different free row.
Each checkout uses a database feature called SKIP LOCKED: if the row you reach for is already taken, it hands you the next free one instead of making you wait. The crowd spreads across every free row instead of queueing behind one. Shopify caps that pool of rows so the search stays fast. And because that hold now sits in the same database as the records, taking the stock and finishing the sale are one all-or-nothing step. Shopify says that step removed the two-system mismatch entirely.
The ceiling was connections, the limited number of callers a database serves at once
The ceiling was connections, the limited number of callers a database serves at once.
Shopify still hit a ceiling, with the database well under its limits. A database takes only so many callers at once, like a desk with a fixed number of phone lines. So the team measured who held those lines longest. That hold was one heavy caller among several. Other checkout code was holding lines too long, because it had never hit the limit first. Clearing that up, and raising one long-untouched setting, lifted the ceiling.
What was impossible five years ago is possible now, with one database feature
What was impossible five years ago is possible now, with one database feature.
Shopify’s engineers draw a wider lesson: before you buy a specialized system, your existing database may already be enough.
The fix was a shape change in a database Shopify already ran
One row for every unit, and an ordinary database sold the last one in stock exactly once.


















