One key gets far more traffic than the rest, and the one cache node holding it melts.
A hot key is one cache key that gets far more traffic than all the others, for example a celebrity profile, a flash-sale item or a viral post.
A cache cluster spreads keys over many nodes with a hash. This works well when keys are about equally popular, because every node then does about the same work. But real traffic is uneven. A few keys are asked for thousands of times more often than the rest. Statisticians often describe this with a Zipf-like curve: the most popular key gets a big share, the next one a smaller share, and the rest a long, thin tail.
Hashing sends every request for one key to the same node. If key A gets 40% of all traffic, then the node that owns A has to answer 40% of all traffic by itself, no matter how many nodes you add.
It matters because a hot key can take down a cache that looks healthy on average.
| Method | How it works | Note |
|---|---|---|
| Per-node monitoring | One node much busier than the others | The first clue, but it does not name the key |
| Key counters or sampling | Count requests per key, or sample a fraction and look at the top keys | Names the key. Sampling keeps the cost low. |
| Client or proxy statistics | The client library or proxy counts the keys it sends | Sees the traffic before it reaches the node |
| Slow or timeout logs | Which keys appear in the slow requests | Shows the damage after it starts |
| Fix | How it works | Good and bad |
|---|---|---|
| Local cache in front | Each app server keeps the hot value in memory for a second or a few | Biggest relief, almost no cache traffic. Values can be slightly stale. |
| Copy the key under several names | Store key#1 ... key#N with the same value. Each copy hashes to a different node and clients pick one | Spreads the load over N nodes. Updating means writing all copies. |
| Read replicas | Replicas of the owning node also answer reads | Spreads reads. Replicas may lag a little. |
| Request coalescing | Many identical requests at one server share a single fetch | Cuts duplicate work, but does not remove the per-server load. |
| Split a hot counter | Keep N sub-counters and add them up when reading | Spreads writes. Reading costs more. |
| Rate limit or shed load | Refuse some requests for the hot key | Protects the node, but some users get nothing. |
Every request for a key goes to the one node that owns the key. Nothing else is done.
A simplified model with 200 keys, a fixed popularity table and a fixed hash, so the same settings always give the same picture. The node limit, traffic numbers and 50 app servers are illustrative, not measurements. Which node owns which key depends on the hash, so the busiest node can move when you change the number of nodes.
| Term | Meaning in easy words |
|---|---|
| Hot key | A key that gets a much larger share of traffic than the others |
| Hot spot | A node, shard or partition that is much busier than the rest |
| Skew | Uneven traffic: a few items are far more popular than the rest |
| Zipf-like | A pattern where the most popular item is much bigger than the next, and so on in a long tail |
| Shard / node | One machine in the cache cluster that owns a set of keys |
| Key copy | The same value stored under several names so that it lands on several nodes |
| Local cache | A small copy kept in each app server’s own memory |
| Request coalescing | Merging many identical requests into one fetch |
| Read replica | A copy of a node that can answer reads |
| Load shedding | Refusing some requests on purpose to protect a node |
| Sub-counter | One part of a counter that is split to spread the writes |
| Choice | We gain | We lose |
|---|---|---|
| Local cache for hot keys | Huge drop in cache traffic | Staleness of a few seconds, more memory per server |
| N copies of a hot key | Load spread over N nodes | N writes per update, more memory |
| Read replicas | More read capacity per key | Replication lag, more machines |
| Rate limiting a hot key | A safe node | Some requests are refused |
| Adding nodes only | Room for other keys | Nothing for the hot key itself |
| Pre-splitting before an event | No surprises on the day | Work and memory for keys that may not get hot |