> the fixes
- LRU-K / 2Q: a key has to be seen twice before it counts as hot
- segmented LRU: new keys start in a probation segment
- LFU: rank by how often, not how recently
Redis has allkeys-lfu for exactly this case.
> the weakness: scan pollution
One big scan (a backup, a report, a SELECT *) reads thousands of keys once.
Each one jumps to the head. Your hot keys slide to the tail and get evicted.
After the scan, the cache is full of junk you won't read again.
> your cache is full
> a new key shows up
> something has to go
> which one do you throw out?
LRU's answer is simple. Kick out the key nobody touched for the longest time.
Here's how it works and why it's O(1)
you don't need a new database to shard.
pick a few keys, hash them, fake it with views first, keep rollback cheap.
great write-up by Sammy Steele on the Figma blog:
figma.com/blog/how-figma…
> did it work?
about nine months to shard the first table. live in September 2023.
the cutover cost 10 seconds of partial availability on primaries. none on replicas.
no latency or availability regressions after.
> Figma's tables hit billions of rows
> They'd maxed out vertical scaling and splitting tables across databases
> One table no longer fits on one machine, and you can't make the machine any bigger
> What do we even do?
517K Followers 2K Followingwaited for agi. i live to experiment. don't take me too seriously I am an idiot. content, games, and tools.
what i do: https://t.co/TTTw6uADaH
20K Followers 268 Following23 | UI Engineer II @wearemiq | Full-Stack Developer | Technical Writer | Can help you with web development and audience building |
39K Followers 600 FollowingSenior Software Engineer @LinkedIn || Former Product intern @Adobe || @Google SPS-‘20 || Learning and Leading || Thoughts of my own || ig- rishikagupta__
43K Followers 2K Followingsoftware , ai research and education | ai @samsung | Startups | Ex-ISRO | Educator | 700K+ YT & IG | Reachout on mail : [email protected]
53K Followers 1K FollowingDevRel Lead @appwrite 🥑📍🛠️ Tinkering with web apps, cloud and AI tools 🧑💻 📍 👨👩👧👦 Bringing writers together at @blrwritersroom 📝
36K Followers 1K FollowingSDE III @Google • Subscribe to my YT channel • Follow for rants, opinions and useful stuff • opinions = mine, not google's https://t.co/t4M1wXKgnt
126K Followers 190 FollowingICPC World Finalist | Competitive Programming Educator @TLE_Eliminators | Software Engineer @Google | Opinions are my own, not my employer's
208K Followers 3K Following🌏 Digital Nomad 🇬🇧🇵🇹🇹🇭
⭐️ GitHub Star of the Year | 👨🏫 GitHub Top Teacher Award
🤓 Developer Advocate @paypaldev
🎙️ Views expressed are my own