Redis & Caching (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
How does Redis handle Big Keys and Hot Keys?
senior LevelredisAdvanced Internals
In Simple Words:
- Big Key: A single key containing millions of items (e.g. a List with 5 million entries). Deleting it with
DELblocks the event loop for seconds!- Fix: Detect with
redis-cli --bigkeys. UseUNLINK(asynchronous background deletion) instead ofDEL.
- Fix: Detect with
- Hot Key: A single key receiving 100,000 QPS, exhausting a single node's network interface.
- Fix: Multi-level caching (client-side memory cache), or key sharding (replicate
hot_keytohot_key_1,hot_key_2across cluster nodes).
- Fix: Multi-level caching (client-side memory cache), or key sharding (replicate