Quick revision
The short answer
At 50 MB and a few changes a minute, the data is small and hot enough that every service should hold all of it in memory; the real design question is how changes reach 40 services within a second. Server-assisted caching with BCAST tracking on the flags: and rules: prefixes over RESP3 does that with no per-key server memory, while pub/sub change events work with any client but need a version-key backstop for lost messages. Either way we load everything at startup, flush and reload on reconnect or failover, cap staleness with a TTL, and promise eventual consistency within about a second, with transaction-critical reads still going to Redis.
What to remember
In this answer, we saw that 50 MB of hot, slowly changing data read 400,000 times per second belongs in every service's memory, and that the design is about invalidation. BCAST tracking over RESP3 gives automatic, millisecond invalidation with no per-key server memory, while pub/sub works with any client but needs a version-key backstop. Both need a full load at startup, a flush and reload on reconnect or failover, and a TTL ceiling, and together they support a promise of eventual consistency within about a second, with critical reads going to the source.
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.
At 50 MB and a few changes a minute, the data is small and hot enough that every service should hold all of it in memory; the real design question is how changes reach 40 services within a second. Server-assisted caching with BCAST tracking on the flags: and rules: prefixes over RESP3 does that with no per-key server memory, while pub/sub change events work with any client but need a version-key backstop for lost messages. Either way we load everything at startup, flush and reload on reconnect or failover, cap staleness with a TTL, and promise eventual consistency within about a second, with transaction-critical reads still going to Redis.
Why this question is asked
Feature flags and pricing rules are read on nearly every request, so they are a classic case where a remote store becomes a bottleneck and a single point of failure. Interviewers like this design question because the obvious answer, cache it locally, is right, but the details of invalidation and failure decide whether the one-second promise holds. In this answer, we will size the problem, describe the two invalidation options in detail, compare them, add the parts both need, and finish with the consistency we can honestly promise.
1Sizing the Problem
Four hundred thousand reads per second against one Redis primary is possible, but it makes Redis the critical path for every request in 40 services, and every read pays a network round trip. The data is only about 50 MB and changes a few times a minute. That ratio, a huge read rate against a tiny, slow-changing dataset, is the strongest signal there is for local caching.
If each service instance keeps the full 50 MB in memory, almost every read becomes a map lookup costing microseconds, and Redis load falls from 400,000 reads per second to whatever it takes to load the data and react to a few changes per minute. So the question is not whether to cache locally but how each instance learns about a change within one second.
2Option 1: Server-Assisted Caching With BCAST
Redis client tracking can send invalidation messages to clients when keys change. In broadcasting mode, a client registers prefixes, and Redis sends it an invalidation for every change under them without storing anything per key. Here we register flags: and rules:. Over RESP3, the protocol version negotiated with HELLO 3, invalidations arrive as push messages on the same connection, typically within milliseconds of the write.
BCAST fits this data well because every service holds every key anyway, so no message is wasted, and with a few changes a minute the message rate is trivial. Client support matters: Lettuce provides ClientSideCaching on top of tracking, and recent Jedis versions add client-side caching over RESP3; the exact APIs and modes supported differ, so check your versions.
3Option 2: Local Caches With Pub/Sub Change Events
The alternative needs no tracking support at all. The service or admin tool that writes a flag publishes a change event on a channel such as config-changes after the write, and every service subscribes and evicts or reloads that key. It works with any client, any Redis-compatible engine, and lets us send richer events, such as a whole new rule set.
But Redis pub/sub is fire-and-forget: a service that is disconnected or slow when the event is published never sees it. So we add a backstop. The writer also increments a version key, config:version, on every change, and each service checks that one small key every two or three seconds. If the version moved and it saw no event, it reloads everything. That turns a lost message into a few seconds of delay instead of indefinite staleness.
7 messages in order. Play them, or step through them one at a time.
The event gives speed; the version check catches events that were lost.
4Comparing the Two
Both meet the one-second target in normal operation. The difference is in what they depend on and how they fail. Server-assisted caching keeps writers simple, since any write is noticed automatically, but needs a client and engine that support RESP3 tracking and has the same message-loss problem on disconnect. Pub/sub requires every writer to publish, which a forgotten script or manual redis-cli fix will skip, unless the version backstop catches it.
| Aspect | BCAST tracking | Pub/sub events |
|---|---|---|
| Client support | RESP3 tracking support needed | Any client |
| Writer duty | None, every write is seen | Must publish (and bump version) |
| Server memory | Prefixes only | None |
| Lost messages | Flush on reconnect | Version key check as backstop |
| Typical delay | Milliseconds | Milliseconds, seconds if lost |
5What Both Designs Need
Three things apply whichever option we pick. First, load the whole dataset at startup, before the service takes traffic, with a SCAN over the prefixes or a single snapshot key. Otherwise 40 services deploying at once each fire thousands of individual reads, a stampede that hits Redis exactly when it is busiest. Second, on any reconnect or failover, flush the local copy and reload it, because invalidations sent during the gap are gone and tracking state is not replicated. Third, give every local entry a TTL of, say, 30 to 60 seconds, so that whatever goes wrong, staleness has a ceiling.
We also measure: the age of the local data, the time from write to the last service applying it, and reload counts. Those numbers are how we prove the promise below.
6What Consistency We Can Promise
We can promise eventual consistency: in normal operation, every service sees a change within about one second, usually within tens of milliseconds. During failures, such as a lost connection or a failover, staleness is bounded by the backstop, either the version check interval or the TTL. We cannot promise that two services see a change at the same instant, or that a read immediately after a write sees it.
For most flags that is fine. For a read that drives money or correctness at the moment of a transaction, such as the final price on an order, the service should read Redis directly, or better, the source of truth, and record the version it used.
7Follow-up questions
How would you test the one-second claim?
Measure it end to end. A test writer changes a canary key, for example flags:canary set to the current timestamp, every few seconds, and every service reports how long after the write its local copy showed the new value, as a histogram metric. We look at p99 and the maximum across all instances, in normal running and while we kill connections, restart Redis and trigger a failover in a staging environment. The claim holds only if p99 stays under a second in normal running and the maximum stays within the stated backstop during failures.
Why not just read Redis for every request with a fast connection?
It works up to a point, but it makes every request in 40 services depend on Redis being up and fast, and it spends 400,000 operations per second to read data that changes a few times a minute. Local copies make the read path faster and keep services running on the last known values if Redis is briefly unavailable.
What if the dataset grows to 5 GB?
Then holding all of it in every instance stops being cheap, and we would cache only the hot part with OPTIN tracking or a bounded cache, or split the data so each service subscribes only to the prefixes it actually uses.
8Conclusion
In this answer, we saw that 50 MB of hot, slowly changing data read 400,000 times per second belongs in every service's memory, and that the design is about invalidation. BCAST tracking over RESP3 gives automatic, millisecond invalidation with no per-key server memory, while pub/sub works with any client but needs a version-key backstop. Both need a full load at startup, a flush and reload on reconnect or failover, and a TTL ceiling, and together they support a promise of eventual consistency within about a second, with critical reads going to the source.
Open with
The data is 50 MB and changes a few times a minute, while reads are 400,000 per second, so every service should hold the whole dataset in memory, and the real design question is invalidation within a second.
Then, if they want more
I see two options. One is server-assisted caching: each service enables CLIENT TRACKING in BCAST mode on the flags: and rules: prefixes over RESP3, so Redis pushes an invalidation for every change on the same connection, with no per-key memory on the server. Lettuce has ClientSideCaching and recent Jedis versions support it, though I would check versions.
The other is pub/sub: the writer publishes a change event and services reload the key. It works with any client, but pub/sub loses messages during disconnects, so I add a version key that writers increment and services check every few seconds.
Either way, services load everything at startup so deployments do not stampede Redis, flush and reload on reconnect or failover, and keep a TTL as a ceiling on staleness. I would promise eventual consistency within about a second normally, bounded by the backstop during failures, and for transaction-critical decisions like a final price I would read the source directly.
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 "Design the caching approach, comparing server-assisted client-side caching with local...": https://scrivio-interview-library.netlify.app/databases/redis-internals/9d06fbf753/