Posts tagged “caching”
-
How do you add a cache node without moving every key?
hash(key) % N moves 91% of keys when you add an 11th node. Consistent hashing, rendezvous hashing and jump hash move 9%. Measured on a million keys: keys moved, balance, lookup cost, and which one to pick.
-
Why did adding a cache make our data wrong?
A cache is a second copy of your data with its own rules, and every way it can disagree with the database shows up as a bug. Five failure modes measured with Redis in front of PostgreSQL, and the fix for each.
-
Which cache eviction policy keeps the most hits?
On skewed traffic, LFU and W-TinyLFU kept 49% hits in a cache holding 1% of keys, against LRU's 40%. A one-off scan cut LRU to 26% for a while. When popularity moved to new keys, plain LFU collapsed from 51% to 13% and stayed there; W-TinyLFU recovered to 47%. Measured, with the code.
-
How do you scale an API?
Find the bottleneck first, then use the cheapest lever that removes it: fix the query, cache the read, pool the connections, add replicas, queue the slow writes, limit each client. Each lever measured on one machine: what it bought, and what it cost.
-
How do you design a URL shortener?
A counter encoded in base62 gives short, unique codes without collision checks; a cache in front of the database serves almost every redirect. The real decisions are 301 vs 302, how to count clicks without slowing redirects, and how to stop abuse.