Quick revision
The short answer
A shared cluster lowers cost and operating effort, but it creates noisy-neighbour risk: one team's large values or hot key can use the memory, CPU and network of a shard that everyone depends on. I would allow a shared cluster for small, well-behaved caches under firm rules (a maxmemory limit with a cache-suitable eviction policy such as allkeys-lru or allkeys-lfu, a TTL on every key, a key prefix per team, a payload size limit and per-team metrics), handle the 50,000 reads per second key with a local L1 cache or request coalescing in the client, and give critical or very large workloads their own instance.
What to remember
In this answer, we weighed a shared Redis cluster against per-team instances. Sharing lowers cost but lets large values, hot keys and missing TTLs from one team hurt everyone on the same shard. For a shared cluster we set maxmemory with allkeys-lru or allkeys-lfu instead of the default noeviction, required TTLs on every key, team prefixes with ACLs, payload limits and per-team metrics. We absorbed the hot key with a short local L1 cache and request coalescing, with replica reads or key replication as alternatives, and gave critical, very large or differently configured workloads their own instances.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A shared cluster lowers cost and operating effort, but it creates noisy-neighbour risk: one team's large values or hot key can use the memory, CPU and network of a shard that everyone depends on. I would allow a shared cluster for small, well-behaved caches under firm rules (a maxmemory limit with a cache-suitable eviction policy such as allkeys-lru or allkeys-lfu, a TTL on every key, a key prefix per team, a payload size limit and per-team metrics), handle the 50,000 reads per second key with a local L1 cache or request coalescing in the client, and give critical or very large workloads their own instance.
Why this question is asked
Sharing one Redis cluster looks like an obvious saving: one thing to run, patch and monitor instead of many. But Redis processes commands for a shard on essentially one thread, and memory is a single pool, so every team's behaviour affects everyone else's latency. The situation in the question has all three classic problems at once: large payloads, a very hot key, and inconsistent eviction settings. Interviewers ask it to see whether we can weigh cost against blast radius and turn that into rules. In this answer, we will recap how a Redis cluster spreads keys and where it breaks down, examine each problem, set the eviction and TTL rules, deal with the hot key, and decide which workloads get their own instance.
1A Quick Recap: How a Redis Cluster Spreads Load
A Redis cluster splits its key space into 16,384 hash slots, and each key belongs to one slot based on a hash of its name. Each primary node, or shard, owns a range of slots, usually with a replica for failover. So load spreads across shards only if keys spread across slots and each key carries a similar share of traffic.
Within a shard, Redis executes commands one after another on a main thread. Newer versions can use extra threads for network I/O, but a slow command or a very large value still delays every other command on that shard. And memory is shared: if one team fills a shard, eviction or write failures hit everyone's keys on it.
2The Noisy-Neighbour Problems in This Setup
Each of the three behaviours in the question harms other teams in its own way.
| Behaviour | What it does to the shared cluster |
|---|---|
| Large payloads (for example 2 MB values) | slow GET/SET block a shard thread; network bandwidth use |
| One key read 50,000 times per second | all load on one shard; its CPU and network saturate |
| No TTLs, no eviction policy | memory fills; with noeviction, writes start failing |
| No prefixes or per-team metrics | nobody can tell which team caused an incident |
3Memory, Eviction and TTL Rules
Open-source Redis defaults to maxmemory-policy noeviction: when memory is full, writes fail with an out-of-memory error, which for a cache means errors in every service that writes. For a cache cluster we set maxmemory below the node's real memory, leaving room for replication buffers and fragmentation, and choose an eviction policy that may evict any key. allkeys-lru evicts approximately least recently used keys; allkeys-lfu evicts least frequently used keys and copes better with one-off scans. The volatile-* policies only evict keys that have a TTL, so they fail just like noeviction when teams forget TTLs.
Even with an LRU or LFU policy, we require a TTL on every key. Eviction is a last resort that chooses victims across all teams; TTLs let each team bound its own data. We also set a payload limit, say 100 KB per value, enforced in the shared client library, with larger objects split, compressed or kept elsewhere.
4Handling the Hot Key
A single key read 50,000 times per second lives in one slot on one shard, so adding shards does nothing for it. If the value is 10 KB, that is about 500 MB per second of network traffic from one node, enough to saturate it and slow every other key on that shard.
The most effective fix is in the client. A local L1 cache, a small Caffeine cache in each instance with a TTL of a second or two, means each of, say, 40 instances asks Redis about once per second instead of thousands of times, turning 50,000 reads per second into about 40. Request coalescing, letting one in-flight request per instance fetch the key while concurrent callers wait for its result, helps in the same way on a miss. Other options are reading from replicas, which spreads load but serves slightly older data, or key replication: storing N copies such as banner:1 to banner:8 in different slots and having clients pick one at random, which spreads the load at the cost of N writes on update.
- 40 service instances50,000 reads per second in total
- Local L1 cache per instanceTTL 1 to 2 seconds, absorbs almost all reads
- Request coalescing on L1 missone Redis call per key per instance
- Redis shard owning the keyabout 40 reads per second instead of 50,000
4 layers, from the top down. Step through them one at a time.
5Prefixes, Limits and Attribution
Every key starts with the team or service prefix, which the starter sets from spring.application.name. With Redis ACLs we can go further and allow each team's user only commands on its own key pattern, so one team cannot overwrite or delete another team's keys. Per-team metrics come from the client side, where the starter tags cache metrics with the service name, and from sampling on the server, for example with redis-cli --bigkeys or MEMORY USAGE on sampled keys per prefix. With those, a latency incident can be traced to a team, and cost can be shown or charged per team, which by itself encourages better behaviour.
6Shared Cluster or Own Instance?
The decision is about blast radius and fit. Small caches with modest traffic, normal value sizes and TTLs are a good fit for the shared cluster: they benefit from shared operations and cost little. A workload gets its own instance when it is critical enough that another team's incident must not affect it, such as checkout or authentication sessions; when it is large, such as tens of gigabytes or values that cannot be made small; or when it needs different settings, such as persistence, a different eviction policy or a different Redis version. The hot-key team can stay shared once its L1 cache is in place, because its load on Redis becomes small. We revisit the placement when metrics show a team outgrowing the shared cluster.
7Follow-up questions
Why is allkeys-lfu often better than allkeys-lru for a shared cache?
LRU evicts by last access time, so a team that scans many keys once can push out other teams' hot keys. LFU evicts by approximate access frequency with decay, so keys read once lose to keys read constantly, which protects the hot sets of well-behaved teams from a neighbour's scan. Both are approximations based on sampling a few keys, which is cheap and good enough for caches.
Does Redis Cluster help with large values?
Not much. Spreading keys over more shards reduces the number of large values per shard, but each large GET still occupies one shard's thread and network for its whole transfer. The real fix is smaller values: cache projections, compress, or split, and enforce a size limit in the client library.
How do you stop a team from bypassing the rules?
Make the starter the easy path, enforce what we can on the server, such as ACLs on key patterns and maxmemory, and make the rest visible. A weekly report of keys without TTL, the largest values and top keys by traffic per prefix usually fixes most problems through conversation rather than policy.
8Conclusion
In this answer, we weighed a shared Redis cluster against per-team instances. Sharing lowers cost but lets large values, hot keys and missing TTLs from one team hurt everyone on the same shard. For a shared cluster we set maxmemory with allkeys-lru or allkeys-lfu instead of the default noeviction, required TTLs on every key, team prefixes with ACLs, payload limits and per-team metrics. We absorbed the hot key with a short local L1 cache and request coalescing, with replica reads or key replication as alternatives, and gave critical, very large or differently configured workloads their own instances.
Open with
I would start by naming the trade-off: a shared cluster is cheaper and easier to operate, but Redis runs commands for a shard on one main thread and memory is one pool, so large values, a hot key or missing TTLs from one team hurt everyone on that shard.
Then, if they want more
So my rules for the shared cluster would be: maxmemory set below real memory with an eviction policy that can evict any key, allkeys-lru or better allkeys-lfu, because the default noeviction makes writes fail when memory is full and volatile policies fail when teams forget TTLs.
Every key gets a TTL and a team prefix, set by the shared starter, and Redis ACLs restrict each team to its own prefix. Values have a size limit, say 100 KB, enforced in the client library. And we collect per-team metrics so incidents and cost can be attributed.
For the key read 50,000 times a second, sharding does not help because it lives in one slot, so I would add a local Caffeine L1 cache with a TTL of a second or two plus request coalescing, which brings Redis traffic down to roughly one read per instance per second.
Replica reads or replicating the key under several names are alternatives. Finally, critical workloads like checkout, very large caches, or caches that need different settings get their own instance; small, well-behaved caches share.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Cache abstraction
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Several teams want to share one Redis cluster for caching. Some cache large payloads...": https://scrivio-interview-library.netlify.app/databases/caching/38aec74c55/