Quick revision
The short answer
Each pod has its own cache and the load balancer spreads requests for a key across all pods, so with 40 pods each pod sees a fortieth of the requests per key and must load every key itself, up to 40 times instead of 6. With fewer requests per key per pod, entries expire or are evicted before they are reused, so less popular keys lose most. We restore the hit ratio with a shared second level such as Redis, with key-based routing through consistent hashing, and by measuring per level and sizing caches for the maximum pod count.
What to remember
In this answer, we saw that local caches lose effectiveness as pods are added, because a round-robin load balancer spreads each key's requests over every pod, each pod loads each key itself, and keys with modest traffic stop being reused before they expire or are evicted. A shared second level such as Redis makes the hit ratio independent of the pod count, consistent-hash routing by key multiplies the effective cache size at the cost of hot-key and remapping care, and measuring hit ratio per level against pod count, with caches sized for maximum scale, keeps it from surprising us again.
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.
Each pod has its own cache and the load balancer spreads requests for a key across all pods, so with 40 pods each pod sees a fortieth of the requests per key and must load every key itself, up to 40 times instead of 6. With fewer requests per key per pod, entries expire or are evicted before they are reused, so less popular keys lose most. We restore the hit ratio with a shared second level such as Redis, with key-based routing through consistent hashing, and by measuring per level and sizing caches for the maximum pod count.
Why this question is asked
Adding pods is supposed to make a service faster, so a falling hit ratio after a scale-out looks paradoxical. Interviewers ask this because it tests whether we understand that a local cache's effectiveness depends on how traffic is divided, not just on its size. In this answer, we will recap how local caches see traffic, work out why more pods mean fewer hits with a simple model, and then go through the options: a shared second level, routing by key, and measuring and sizing for maximum scale.
1How Each Pod Sees the Traffic
A local cache, here Caffeine with 20,000 entries, lives inside one pod and is filled only by that pod's requests. A round-robin or least-connections load balancer sends each request to any pod, regardless of which key it asks for. So every pod ends up asking for nearly every popular key, and every pod must load each key once before it can hit.
With 6 pods, a key is loaded at most 6 times per TTL window and then served from 6 warm copies. With 40 pods, the same key is loaded up to 40 times, and each copy serves far fewer requests before it expires.
2Working It Out With a Simple Model
Take one key requested r times in a 10-minute TTL window, spread evenly over N pods. Every pod that receives at least one of those requests misses once, then hits. So the key's hit ratio is roughly 1 minus the number of pods that saw it divided by r. A key requested once a second, r = 600, barely notices: 6 misses out of 600 with 6 pods, 40 out of 600 with 40. But a key requested 12 times in the window is hit about half the time with 6 pods and almost never with 40, because most of those 12 requests now land on a pod that has never seen the key.
| Requests per TTL window | 6 pods | 40 pods |
|---|---|---|
| 600 (1 per second) | 99 percent | 93 percent |
| 60 | 90 percent | 48 percent |
| 12 | 56 percent | 13 percent |
Eviction makes it worse. Caffeine keeps entries it judges likely to be reused, based on how often they were requested. When each pod sees only a fortieth of a key's requests, moderately popular keys look unpopular and are evicted earlier, before their next request arrives. So the overall hit ratio fell from 92 to 61 percent, and the backing store received several times more loads, exactly when traffic had increased.
3Option 1: A Shared Second Level
Put a shared cache such as Redis behind the local caches. A local miss now asks Redis, where the key is stored once for all 40 pods, so its hit ratio does not depend on the pod count at all. A key loaded by any pod is a Redis hit for the other 39. Each local miss costs about a millisecond instead of a backing-store call, and the backing store sees roughly one load per key per Redis TTL.
This is usually the first fix, because it needs no change to routing and it makes the cache behave predictably under autoscaling. The local level stays useful for the hottest keys, and the shared level carries the long tail.
4Option 2: Route Requests by Key
Instead of spreading each key over all pods, we can send all requests for a key to the same pod. Consistent hashing on the key, for example the user or product id taken from a header or the path, maps each key to one pod on a hash ring. Load balancers such as Envoy (ring hash or Maglev) and NGINX (hash with the consistent option) support this. Now each pod caches only its own share of the keys, so the 40 pods together hold 40 times 20,000 distinct entries, and each key is loaded once rather than 40 times.
There are two things to watch. Hot keys: a single very popular key now lands on one pod, which can overload it, so very hot keys need to be spread over a few pods or served from the local cache of every pod; bounded-load variants of consistent hashing help. And remapping: when pods are added or removed, the keys that move start cold on their new pod. Consistent hashing keeps that to about 1/N of the keys per change, but frequent scaling still causes bursts of misses.
5Measuring and Sizing for the Maximum Scale
Finally, the failure was hard to predict because the cache was sized and judged at 6 pods. The hit ratio of each level should be a dashboard metric plotted against the pod count, so a scale-out that degrades caching is visible immediately. And local cache sizes and TTLs should be chosen for the largest pod count autoscaling allows, not the smallest: a longer local TTL for stable data or a larger maximum size helps when each pod sees fewer requests per key.
6Follow-up questions
How does key-based routing interact with autoscaling?
Every scale event changes the hash ring, so about 1/N of the keys move to a different pod and start cold there. Scaling out adds a brief miss bump; scaling in moves the removed pod's keys. If the autoscaler scales up and down often, those bumps add up, so we slow scale-in, and with a shared Redis level behind the local caches the moved keys become Redis hits instead of backing-store loads, which makes the remapping cheap.
Is a bigger local cache the answer?
Only partly. A larger cache keeps more entries, but it does not change the fact that each pod must load each key itself and sees fewer requests per key. It also multiplies memory across all 40 pods. A shared level or key routing addresses the cause.
Why not use sticky sessions instead?
Sticky sessions route by user, which helps only if the cached data is per user. For data keyed by product, many users ask for the same product, and sticky sessions spread those requests over all pods again.
7Conclusion
In this answer, we saw that local caches lose effectiveness as pods are added, because a round-robin load balancer spreads each key's requests over every pod, each pod loads each key itself, and keys with modest traffic stop being reused before they expire or are evicted. A shared second level such as Redis makes the hit ratio independent of the pod count, consistent-hash routing by key multiplies the effective cache size at the cost of hot-key and remapping care, and measuring hit ratio per level against pod count, with caches sized for maximum scale, keeps it from surprising us again.
Open with
Each pod has its own Caffeine cache, and the load balancer sends requests for the same key to any pod. With 6 pods each pod sees a sixth of a key's requests; with 40 it sees a fortieth.
Then, if they want more
So every key is loaded up to 40 times instead of 6, and for keys that are not very popular, most requests now land on a pod that has never seen them. A key requested 60 times in a ten-minute window goes from about 90 percent hits to about half.
Fewer requests per pod also means entries look less popular to the eviction policy and expire or get evicted before reuse. To fix it, the first option is a shared second level like Redis behind the local cache: a local miss becomes a one-millisecond Redis hit, and Redis's hit ratio does not depend on the pod count.
The second is routing by key with consistent hashing, for example on the product id in Envoy or NGINX, so each key goes to one pod and the effective cache size becomes 40 times larger.
Then I need to handle hot keys that would overload one pod, and remapping when pods change, which only moves about one fortieth of the keys. And I would track hit ratio per level against pod count and size caches for the maximum scale.
About this answer
- Last updated
- 13 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 official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
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 "Why did adding pods make the cache worse, and what are your options to restore the hit...": https://scrivio-interview-library.netlify.app/architecture/caching-strategies/5edd4d2041/