Shopify increased their write throughput by 50% moving one of their MySQL keys from UUIDv4 to ULID.
But How?
When you make a purchase, Shopify guarantees idempotency by having the client uniquely tagging the request using UUID. If you accidentally replay the request and they check if the request exists or not and no-op.
UUIDs (at least version 4) are random while order placements are ordered, this leads to thrashing pages in and out of the buffer pool as it fills up dramatically slowing down writes.
Shopify replaced their primary key to ULID which is ordered and timestamped so now requests are chronologically ordered and as a result requests in a given time period live almost in the same pages and recent request (which is the common query) live in tail pages keeping those hot in memory.
Also worth mentioning that UUIDv7 and 8 are ordered and work as well, this is specific to UUIDv4.
Watch my full coverage on this amazing change, truly show engineers knowing what they are doing
The topic of UUID is surfacing again so I thought I’d share this again
https://lnkd.in/gdUwpDEU
—-
Get my fundamentals of database engineering to learn low level database internals https://databases.win
But How?
When you make a purchase, Shopify guarantees idempotency by having the client uniquely tagging the request using UUID. If you accidentally replay the request and they check if the request exists or not and no-op.
UUIDs (at least version 4) are random while order placements are ordered, this leads to thrashing pages in and out of the buffer pool as it fills up dramatically slowing down writes.
Shopify replaced their primary key to ULID which is ordered and timestamped so now requests are chronologically ordered and as a result requests in a given time period live almost in the same pages and recent request (which is the common query) live in tail pages keeping those hot in memory.
Also worth mentioning that UUIDv7 and 8 are ordered and work as well, this is specific to UUIDv4.
Watch my full coverage on this amazing change, truly show engineers knowing what they are doing
The topic of UUID is surfacing again so I thought I’d share this again
https://lnkd.in/gdUwpDEU
—-
Get my fundamentals of database engineering to learn low level database internals https://databases.win