Quick revision
The short answer
I would put one read-through policy cache service, owned by one team, between the new apps and the legacy system, so only it ever calls the legacy system, through a rate limiter and a concurrency cap that hold it under 500 requests per second whatever happens. The cache is filled proactively from a bulk export of active policies and kept fresh from change notifications or a modified-since poll, so almost every read is a hit served from Redis in a few milliseconds. Long TTLs and serving stale values protect callers when the legacy system is slow or down, concurrent misses are coalesced and queued behind the limiter, and miss rate, legacy calls per second and staleness are the key metrics.
What to remember
In this answer, we designed a single read-through policy cache service that is the only caller of the legacy system, with a rate limiter and concurrency cap that keep it under 500 requests per second. The cache is filled from a bulk export and refreshed from change notifications or a modified-since poll, so reads almost never miss. Coalescing, priority queues and failing fast protect the budget; long TTLs, serving stale data and replicated Redis protect the callers; and miss rate, legacy calls per second and staleness show whether it is working.
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.
I would put one read-through policy cache service, owned by one team, between the new apps and the legacy system, so only it ever calls the legacy system, through a rate limiter and a concurrency cap that hold it under 500 requests per second whatever happens. The cache is filled proactively from a bulk export of active policies and kept fresh from change notifications or a modified-since poll, so almost every read is a hit served from Redis in a few milliseconds. Long TTLs and serving stale values protect callers when the legacy system is slow or down, concurrent misses are coalesced and queued behind the limiter, and miss rate, legacy calls per second and staleness are the key metrics.
Why this question is asked
Putting a modern, high-traffic front end on a slow legacy system is one of the most common design problems in large companies. The legacy owners have a hard limit, the new apps have a hard latency target, and a naive cache meets both only on good days. Interviewers ask this to see whether we design for the bad days: a cold start, a burst of misses, the legacy system going down. In this answer, we will set out the requirements and numbers, sketch the architecture, explain how the cache is filled and refreshed, go deep on protecting the legacy budget, handle failures, and size the store.
1Requirements and Rough Numbers
The new apps need 20,000 lookups per second at under 50 ms. The legacy system answers in 300 ms and allows at most 500 requests per second. Policies change a few thousand times a day, only through the legacy system. So reads outnumber changes by a huge margin: 20,000 per second against perhaps 5,000 per day, which is about 0.06 per second.
Two conclusions follow at once. The cache must answer essentially all reads: at 20,000 reads per second, the 500 per second budget allows a miss ratio of at most 2.5 percent, and with 300 ms per legacy call even that would break the 50 ms target for those requests. So a cache that fills on demand is not enough; it must be filled in advance. And because changes are rare, keeping a full copy fresh is cheap. Suppose there are 5 million active policies of about 4 KB each: that is about 20 GB, which fits comfortably in a Redis deployment.
2The High-Level Design
All new apps call one policy cache service; none call the legacy system directly. The service reads from Redis, and only it talks to the legacy system, through a single gateway component with the rate limiter. Owning this in one team matters: if each app built its own cache, each would make its own legacy calls, and nobody could guarantee the 500 per second total.
- Customer-facing apps20,000 lookups/s, need < 50 ms
- Policy cache serviceread-through API; coalesces misses; serves stale when needed
- Redis (replicated across zones)full copy of active policies, ~20 GB
- Legacy gatewayrate limiter 450/s + concurrency cap; refresh queue with priorities
- Legacy policy system300 ms per lookup, hard limit 500/s; source of truth
- Change feednotifications, change log or modified-since poll
6 layers, from the top down. Step through them one at a time.
3Filling and Refreshing the Cache
We fill it proactively. Calling the lookup API for 5 million policies at 450 per second would take about 3 hours, and that uses the whole budget, so a bulk export, a file or database extract of all active policies agreed with the legacy owners, is better. It loads the cache in minutes without touching the online limit.
After that, the cache follows changes. The best source is a change notification or a change log from the legacy system, a message per changed policy. If none exists, we poll a modified-since query every minute. Each change triggers a refresh of that policy through the gateway, a few thousand calls a day, a tiny fraction of the budget. The data model in Redis is simple: one key per policy, such as policy:{number}, holding the serialized policy plus metadata: when it was loaded and the legacy version or timestamp, so we can tell how fresh it is.
4The Hard Part: Never Exceeding 500 Requests per Second
The legacy limit must hold whatever happens, including bugs, cold starts and traffic spikes, so it is enforced at one choke point, the gateway, not by good behaviour. The gateway has a rate limiter set below the limit, say 450 per second, to leave headroom for the legacy owners' own users and measurement error. It also has a concurrency cap: at 300 ms per call, 450 calls per second means about 135 in flight (Little's law), so we cap it at around 150. If the legacy system slows to 1 second per call, the cap automatically lowers our rate instead of piling more load onto a struggling system.
Misses are coalesced: if 200 requests arrive for the same missing policy, the service makes one legacy call and all 200 wait for it. Requests that cannot be served within the budget are queued by priority. Interactive misses from customers come first, change-driven refreshes next, and background reconciliation last. When the queue is too long, low-priority work is delayed, and if interactive misses still exceed the budget, the service fails fast with a clear error rather than queuing forever.
- App asks for policy P
- In Redis?YesReturn it (about 2 ms)NoTreat as a miss
- Load for P already in flight?YesWait for that resultNoQueue a legacy call, high priority
- Within rate and concurrency limits?YesCall legacy (300 ms), store, returnNoWait in queue, or fail fast after a deadline
- Record miss, legacy call and staleness metrics
5 steps in order. Play them, or step through them one at a time.
5Failure Handling: Serving Stale Data
When the legacy system is slow or down, the cache keeps serving what it has. Long TTLs, days rather than minutes, are a safety net, not the freshness mechanism, so an outage does not empty the cache. Responses can carry the loadedAt time, and callers that care, such as a claims process, can decide that data older than some limit is not good enough. If the change feed breaks, the data quietly ages, so we alert on the feed's lag.
Redis itself must not be a single point of failure: we run it with replicas across availability zones, Sentinel or Redis Cluster for failover, and persistence so a restart does not force a reload. If Redis is lost entirely, the bulk export reloads it, and in the meantime the gateway's limiter protects the legacy system from the flood of misses.
6Sizing and Key Metrics
For 20 GB of data, a Redis Cluster of three primaries with one replica each, at roughly 7 GB per primary, leaves room for growth and for memory overhead. 20,000 simple GETs per second is light work for Redis; the cache service itself needs a handful of instances behind a load balancer.
Three metrics tell us whether the design is working. The miss rate should be close to zero in steady state; a rise means the fill or the feed is broken. Legacy calls per second should sit far below 450, with the limiter's rejections at zero. And staleness, the age of the data served relative to the latest change, shows whether the change feed is keeping up.
7Follow-up questions
How would you handle a policy that changed but whose notification was lost?
With reconciliation that does not depend on notifications. A modified-since poll every few minutes catches anything the feed missed in that period, and a nightly comparison of the cache against a bulk export, comparing legacy versions or checksums per policy, catches everything else, including entries that changed while the export was being taken. Both run through the gateway's low-priority queue or through the bulk channel, so they never compete with customer requests. The TTL is the last safety net: even a missed change is refreshed within the TTL.
Why not let each app use its own local cache?
Because the legacy budget is shared. Twenty apps with their own caches would each make their own misses and refreshes, and nobody could enforce the 500 per second total. One service with one gateway makes the limit enforceable and the data consistent across apps.
8Conclusion
In this answer, we designed a single read-through policy cache service that is the only caller of the legacy system, with a rate limiter and concurrency cap that keep it under 500 requests per second. The cache is filled from a bulk export and refreshed from change notifications or a modified-since poll, so reads almost never miss. Coalescing, priority queues and failing fast protect the budget; long TTLs, serving stale data and replicated Redis protect the callers; and miss rate, legacy calls per second and staleness show whether it is working.
Open with
The numbers drive the design. 20,000 reads per second against a 500 per second budget means at most 2.5 percent misses, and a 300 millisecond legacy call breaks the 50 millisecond target anyway, so the cache must be filled in advance rather than on demand.
Then, if they want more
Changes are rare, a few thousand a day, so keeping a full copy fresh is cheap.
I would build one read-through policy cache service, owned by one team, that every app calls; only it calls the legacy system, through a gateway with a rate limiter at about 450 per second and a concurrency cap of around 150, so the limit holds whatever happens.
I would fill Redis from a bulk export of all active policies, then refresh changed policies from change notifications, or a modified-since poll if there are none. Concurrent misses for a policy are coalesced into one call, refreshes queue behind customer misses, and low-priority work is delayed or shed before the budget runs out.
TTLs are long, as a safety net, and when the legacy system is slow or down we serve stale data and tell callers how fresh it is. Redis is sized for the whole active set, maybe 20 gigabytes, with replicas across zones.
The key metrics are miss rate, legacy calls per second and staleness, plus a nightly reconciliation for lost notifications.
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 "Design a caching layer that meets the new load without breaking the legacy limit...": https://scrivio-interview-library.netlify.app/architecture/caching-strategies/dd258b98a3/