Quick revision
The short answer
The invalidation table is full. In default tracking mode Redis keeps an entry for every key any of the 60 pods has read, and when the table reaches tracking-table-max-keys, one million by default, Redis evicts entries by sending invalidations for keys that never changed. That costs the memory and CPU we see and empties the pods' caches, which explains the low hit rate. The fix is to track only what is worth caching, with OPTIN or a few BCAST prefixes, keep local caches small, and raise the limit only after measuring.
What to remember
In this answer, we saw that default tracking keeps an invalidation table entry for every key the 60 pods read. At one million keys, the default tracking-table-max-keys, Redis evicts entries by sending invalidations for unchanged keys, which costs memory and CPU and empties the local caches. The fix is to track only hot, stable keys with OPTIN or a few BCAST prefixes, keep local caches small, raise the limit only after measuring, and watch the tracking counters and invalidation rate afterwards.
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.
The invalidation table is full. In default tracking mode Redis keeps an entry for every key any of the 60 pods has read, and when the table reaches tracking-table-max-keys, one million by default, Redis evicts entries by sending invalidations for keys that never changed. That costs the memory and CPU we see and empties the pods' caches, which explains the low hit rate. The fix is to track only what is worth caching, with OPTIN or a few BCAST prefixes, keep local caches small, and raise the limit only after measuring.
Why this question is asked
Client-side caching is supposed to save Redis work, so it is surprising when switching it on makes Redis busier and the caches barely hit. This scenario is a good interview question because the symptoms point at a specific mechanism that people rarely read about until it bites them. In this answer, we will recap what default tracking stores on the server, see how the one-million-key limit turns into false invalidations, explain each symptom from that, and then reconfigure the caching and decide what to watch afterwards.
1What Default Tracking Stores on the Server
In default mode, CLIENT TRACKING ON makes Redis record every key a tracked connection reads. The record lives in an invalidation table, which maps each key name to the set of client ids that may hold a copy. When the key changes, Redis sends each of those clients an invalidation and removes the entry.
With 60 pods each reading a broad slice of the keyspace, the table quickly holds an entry for nearly every key read by anyone, and each entry lists up to 60 client ids. That memory is on top of the data itself. INFO reports its size as tracking_total_keys, the number of keys in the table, and tracking_total_items, the total number of client references across them.
2How the Limit Turns Into False Invalidations
To stop the table growing without bound, Redis has the setting tracking-table-max-keys, which defaults to 1,000,000. When the table is full and a new key must be recorded, Redis makes room by evicting existing entries. It cannot just forget an entry silently, because the clients holding those keys would then never hear about a change. So for each evicted entry it sends an invalidation to the clients listed, exactly as if the key had been modified.
- Pod reads a new keyRedis must add it to the table
- Table at 1,000,000 keys?tracking-table-max-keysYesEvict an existing entryNoJust add the entry
- Send invalidation for evicted keyKey did not change
- Pods drop a good local copyNext read misses and goes to Redis
- That read adds a key againThe cycle repeats
5 steps in order. Play them, or step through them one at a time.
Under pressure the table churns, and every churn is a wasted message and a lost cache hit.
3Explaining Each Symptom
Now every symptom has a cause. The memory grew by about 2 GB because a million table entries, each with a key string and a set of client ids, plus the per-client bookkeeping, are all held by Redis. The CPU grew by 20 percent because Redis is constantly evicting entries and pushing invalidation messages to pods, on its single main thread, for keys nobody changed.
The local hit rate is low because the pods' caches are being emptied by table pressure rather than by writes. tracking_total_keys sitting near 1,000,000 is the giveaway: the table is pinned at its limit, so every new read pushes out an old one. Notice that this is not a bug in the pods. They are doing exactly what tracking asks; the configuration asks Redis to track far more than is worth caching.
4Reconfiguring: Track Only What Is Worth Caching
Local caching pays off for keys that are read often and change rarely, such as configuration, product reference data or feature flags. It is wasted on keys read once, such as a session or an order looked up for one request. So we stop tracking everything.
The first option is OPTIN mode. Reads are not tracked unless the client sends CLIENT CACHING yes right before them, so the application opts in only for hot, stable keys and the table holds only those.
| Mode | Server memory | Messages | Fits |
|---|---|---|---|
| Default, track all reads | Entry per key read | Precise | Small keyspace, few clients |
| Default with OPTIN | Entry per opted-in key | Precise | Hot keys mixed with one-off reads |
| BCAST with prefixes | Prefixes only | Every change under prefix | Small hot dataset, rare writes |
The second option is BCAST mode with a few prefixes, for example CLIENT TRACKING ON BCAST PREFIX config: PREFIX product:ref:. Redis then stores only prefixes, not keys, and sends every change under them to all subscribed pods. This works well for a small hot dataset; it works badly if the prefix covers keys that change constantly, because every pod hears about every change.
Alongside either option, keep each pod's local cache small and bounded, say tens of thousands of entries with a maximum TTL. Raise tracking-table-max-keys only if, after narrowing what is tracked, the useful working set still exceeds the limit, and only after measuring how much memory each extra key costs. Tracking millions of keys for 60 pods rarely pays off: most of those keys are read too rarely for the local copy to be hit again.
5What to Watch After the Change
We confirm the fix with numbers. In INFO, tracking_total_keys should fall far below the limit with OPTIN, tracking_total_items should fall with it, and with BCAST tracking_total_prefixes should show the handful of prefixes we expect. Redis memory and CPU should return close to the levels before caching was enabled.
On the pods, we watch the local hit rate, which should rise sharply for the opted-in keys, and the invalidations received per second, which should now track the real write rate of those keys instead of table churn. If invalidations stay high while writes are rare, something is still tracking too much.
6Follow-up questions
When does BCAST mode itself create too much traffic?
When the prefixes cover keys that are written often, or a large keyspace that most pods do not cache. Every write under a prefix becomes one message to every subscribed connection, so 5,000 writes per second under a prefix with 60 pods is 300,000 messages per second, most of them about keys the pod never held. BCAST is right when the dataset is small, hot on every pod, and rarely written.
Why not simply set tracking-table-max-keys to 0, meaning no limit?
Because then the table grows with every key any pod ever reads, and Redis memory grows with it, possibly until maxmemory eviction starts removing real data. The limit exists to protect the server; the right move is to track less.
Could the pods use their own TTL cache without tracking instead?
Yes, for data that may be a few seconds stale, a plain TTL cache with no tracking puts zero load on Redis. Tracking is worth its cost only where we need changes to show up quickly and the keys are read many times between changes.
7Conclusion
In this answer, we saw that default tracking keeps an invalidation table entry for every key the 60 pods read. At one million keys, the default tracking-table-max-keys, Redis evicts entries by sending invalidations for unchanged keys, which costs memory and CPU and empties the local caches. The fix is to track only hot, stable keys with OPTIN or a few BCAST prefixes, keep local caches small, raise the limit only after measuring, and watch the tracking counters and invalidation rate afterwards.
Open with
In default tracking mode Redis records every key each tracked connection reads, with the list of clients holding it, so 60 pods reading broadly fill that table fast. tracking_total_keys near a million tells me it is at tracking-table-max-keys, which defaults to one million.
Then, if they want more
When it is full, Redis makes room by evicting entries, and it has to send an invalidation for each evicted key so clients do not keep copies it no longer tracks. So the pods are receiving invalidations for keys that never changed.
That explains all three symptoms: the table and client references cost the 2 GB, the constant eviction and message sending cost the CPU, and the pods' caches are emptied by table pressure rather than real writes, which is why the hit rate is poor. I would reconfigure to track only what is worth caching.
Either OPTIN mode, where the client sends CLIENT CACHING yes before reads of hot, rarely changing keys, or BCAST with a few prefixes for a small hot dataset.
I would keep the local caches small and bounded with a max TTL, only raise the limit after measuring, and then watch tracking_total_keys, tracking_total_items and tracking_total_prefixes, plus the invalidation rate the pods see.
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 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
- Redis documentation
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 "What is going on, and how would you reconfigure the caching?": https://scrivio-interview-library.netlify.app/databases/redis-internals/b11161b1fa/