Live data from Hacker News

We replaced Redis with MySQL for inventory reservations and it scaled

shopify.engineering

41–50 of 281 posts

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

#41
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

This is Shopify, the leadership is full steam ahead on AI in a big way and they review employee performance based on AI usage.

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

#42
post #14

Earlier quoted context omitted.

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.

Are you implying that vaping is far right?

Sounded to me like they were saying people vape in the office, which would make a bad work environment on top of the far right bros.

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

#43
post #8

> Instead of one row per item with a quantity column, we use one row per sellable unit. An item with 10 units has 10 rows. > But one row per unit for all inventory would break down at scale—an item with 50,000 units across 10 locations would mean 500,000 rows, and the reserve query would slow as it scans through them. Instead, we maintain a bounded pool of available rows, capped at 1,000 per item/location combination…

Depends on the scale. Most companies don't approach the scale where this matters.

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

#44

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]

I actually don't think this article was LLM generated but these two sentences suck. I think they were moved from another part of the article without being modified.

First, "the hardest lesson". What lesson? It is out of context. Nobody was talking about lessons before this.

Second, "the bottleneck wasn't what we were measuring and observing". Of course the bottleneck itself wasn't that. They couldn't discover what the bottleneck was using the information in their measurements and observations.

It is a clunky and frankly incorrect passage in an otherwise well written article.

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

#45
post #37

Earlier quoted context omitted.

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.

Yes, the point is to spread contention across multiple rows. They also mention this in the beginning of the article

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

#46
not the best design to have 1000 rows for each shop*SKU combination. If a candidate proposed this solution during Shopify's System Design interview, i doubt he would be vetted for Senior+ position.

Instead of having 1000 rows per shop*SKU, why not just have one row per shopping cart*SKU?

That way a single row would represent a single cart, and will hold info of multiple items of the same SKU.

No need a cludge with 1000 rows limit and replenishment process. Instead of dealing with N rows, you always deal with a single row.

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

#49
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…

I was investigating Durable Objects (DO) and had Fable walk me through where in my app they might be appropriate. One place had a dependency with billing (where I use a transaction now) and the proposed re-work to allow for concurrent editing with DO looked very much like this, reservations with idempotency keys. And if you add hierarchical allotments then it scales pretty well.

I disagree with the other posters about the bg process, if you have any bg processing already you should be able to handle the few edge cases without too much trouble.

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

#50

Earlier quoted context omitted.

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?

Why are you trying to get someone to repeat slurs?
Post reply on HN