Live data from Hacker News

We replaced Redis with MySQL for inventory reservations and it scaled

shopify.engineering

31–40 of 281 posts

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#31
post #23
post #21

It seems there could be a simpler solution. 1. Deduct the reservation from the inventory when the user starts to order, but in the same txn also maintain a separate row for the in progress order flow. 2. If the order flow is aborted or times out have a background process that returns these to the inventory. That seems simpler than this approach and involves no locking. Though their presented approach is also reasonab…

now you have two problems. what happens when your reservation system backs up?

[dead]

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#32
post #28

They were really so proud of that AI image that they just had to tack it on at the end? Did nothing but make the blog post feel like cheap mass produced slop

The blog probably was.shopify was pretty early and publicly all in on using AI for everything

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#33
post #21

It seems there could be a simpler solution. 1. Deduct the reservation from the inventory when the user starts to order, but in the same txn also maintain a separate row for the in progress order flow. 2. If the order flow is aborted or times out have a background process that returns these to the inventory. That seems simpler than this approach and involves no locking. Though their presented approach is also reasonab…

The moment you added a background process you just replaced the complexity. 1. Backgrounds process can back up 2. They need context of the user and need to switch context per user 3. What if they fail, you create some DLQ or another process to handle the failure 4. Who looks on those failure and how do they act TLDR; there is always a cost

The design in the shoppify post already had a background process for the item replenishment.

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#35
post #6

"But the hardest lesson wasn't about database design. It was discovering that the real bottleneck wasn’t what we were observing and measuring."

It's honestly weird Claude converges on this language because it's incredibly wordy and hard to parse. One would think semantic density would win out in training.

[flagged]

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#36
post #29
post #21

It seems there could be a simpler solution. 1. Deduct the reservation from the inventory when the user starts to order, but in the same txn also maintain a separate row for the in progress order flow. 2. If the order flow is aborted or times out have a background process that returns these to the inventory. That seems simpler than this approach and involves no locking. Though their presented approach is also reasonab…

My understanding is: your proposal is not very different from what Shopify is doing except they are tracking 'reserved units' (one per row) and you are proposing tracking 'orders' as the temporary state to then reconcile back with inventory quantities.

Yes, at a high level. It doesn't rely on skip locked, which is not cheap at DB level. DB has to still typically run query and keep going until it finds an unlocked item. Deducting and checking inventory counts are simpler ops inside the DB.

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#37
post #21

It seems there could be a simpler solution. 1. Deduct the reservation from the inventory when the user starts to order, but in the same txn also maintain a separate row for the in progress order flow. 2. If the order flow is aborted or times out have a background process that returns these to the inventory. That seems simpler than this approach and involves no locking. Though their presented approach is also reasonab…

Can you clarify why this involves no locking? There can still be 2 actors fighting for the same row.

Two concurrent deductions of inventory do contend but only during the actual DB update. That is just normal DB locking for SQL isolation levels. The blog refers to explicit locking by the app, which is where skip locked comes in.

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#38

Shopify’s founder and their coo both fund far-right extremism, and its founder thinks only rich people should be able to vote. But anyway, they switched databases. https://www.techwontsave.us/episode/340_shopifys_leaders_are...

Yeah it's an awful place to work unless you're a far-right bro. My old director used to use slurs and vape in the office. The founder hires pro gamers with no technical expertise because he thinks they're cool.

Don't get shy now. Which slurs?

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#39

Earlier quoted context omitted.

It's honestly weird Claude converges on this language because it's incredibly wordy and hard to parse. One would think semantic density would win out in training.

[flagged]

It's not hard to parse, but it's a dense pair of sentences that say nothing. It just pads the length of the article and gives readers mental fatigue trying to read between the lines to figure out what the point is.

Re: We replaced Redis with MySQL for inventory reservations and it scaled

#40
post #6

"But the hardest lesson wasn't about database design. It was discovering that the real bottleneck wasn’t what we were observing and measuring."

But was it load bearing?

load = bearing

gun = smoking

insight = key

gap = closed

summary = executived

Post reply on HN