Scaling a cache cluster and hot keys

Caching and Redis Senior Python 3.13+ PostgreSQL 17+ Reviewed By Best Latest Apps

Pick the fix

A celebrity's profile key gets 200,000 reads a second, all on one cluster node. Best fix?

Options
Hint 1 of 1

Does adding shards move one key?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Keep a few-second in-process copy in each app server, and/or replicate it under several suffixed keys

Correct. Spreads one key's load across many places.

Cluster sharding spreads different keys across nodes, but one key always lives on one slot. A hot key needs copies: a short in-process cache or several suffixed replicas that readers pick from.

Why not the others?
  • B Add more cluster shards. The key still hashes to one slot.
  • C Increase its TTL. TTL doesn't change read load.
  • D Move it to the database. Worse.

30-second answer

Shard keys across nodes: Redis Cluster splits the keyspace into 16,384 hash slots spread over primaries, and clients route each key to its slot; client-side consistent hashing does the same for independent nodes. Add replicas to scale reads. A single hot key still lands on one node, so replicate it under several key names and pick one at random, or keep a short-lived in-process copy in each app instance.

Practise saying it · 30 s. No recording, just a timer

How do you scale a cache?

Say your answer out loud, then check which of these points you covered:

  • Shard by hash slot
  • Replicas for reads
  • Hash tags for multi-key
  • Hot key: copies or near-cache

Deep dive

Multi-key commands in Redis Cluster need all keys in one slot; hash tags {user:42}:cart force that.

Resharding moves slots between nodes online.

Measure per-key load (redis-cli --hotkeys with an LFU policy, or client-side metrics).

A local in-memory cache in front of Redis takes the hottest reads but adds another staleness window.

Common mistakes

  • Expecting more shards to fix one hot key.
  • Multi-key transactions across slots.
  • Using KEYS or large SMEMBERS on a busy cluster.

Senior take & follow-ups

Explain slots and routing, read replicas, and hot-key techniques.

Follow-up questions

Think of your answer first, then open the hint.

  1. What's a hash tag?

    Show hint

    The part in braces decides the slot, so related keys share a node.

  2. How do you spread a hot key?

    Show hint

    Copies under suffixed names, or a local near-cache.

Suggest a fix if something here is wrong or out of date.