One row for every sellable unit, and each checkout takes any free one
3 months ago
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.
Ask about this presentation
Chapters
0:00One row for every sellable unit, and each checkout takes any free one
0:13Finishing a sale needed two writes that could not be made one step
0:30Ten units in stock is now ten rows
0:40Thousands of checkouts reserve at the same time, because each takes a different free row
1:10The ceiling was connections, the limited number of callers a database serves at once
1:37What was impossible five years ago is possible now, with one database feature
1:45The fix was a shape change in a database Shopify already ran
Show transcriptHide transcript
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.
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.
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.
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.
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.
Shopify’s engineers draw a wider lesson: before you buy a specialized system, your existing database may already be enough.
One row for every unit, and an ordinary database sold the last one in stock exactly once.
Up next
1:48Writing a note down as one thing is what made it fast
@the-daily-build
3 months ago
1:51Nothing on the rig measures speed
@the-daily-build
3 months ago
1:53A file gets smaller when you can guess what is in it
@the-daily-build
3 months ago
1:55The seal on an AI's private thinking had one key for the whole company
@the-daily-build
3 months ago
1:42A single CPU instruction, stretched from a blink to a full minute
@the-daily-build
3 months ago
1:44You can't be best at everything
@the-daily-build
3 months ago
1:42How deleting one if-statement made this filter 4x faster
@the-daily-build
3 months ago
1:42Software gives you five skin tones, or sixteen million
@the-daily-build
3 months ago
1:43A Self-Spreading Worm Got Into the Code Behind Billions of Installs
@the-daily-build
3 months ago
1:34The AI session you can’t take with you
@the-daily-build
3 months ago
1:42He Walked Through His House Before It Was Built, at Full Size, in a Headset
@the-daily-build
4 months ago
1:38500 Lines of Code That Draw 3D Without a Graphics Card
@the-daily-build
4 months ago