Quick revision
The short answer
The main risk is invalidation, so first every writer invalidates both clusters for the whole transition; only then do we warm the new cluster, by letting readers that miss on it fall back to the old one and copy the value across and by pre-copying the hottest keys. We move readers service by service and percentage by percentage behind flags, compare values with shadow reads, watch database load with concurrency limits in place, and retire the old cluster and the dual-invalidation code only after the rollback window ends.
What to remember
In this answer, we planned a cache migration around its two real risks, stale data and a cold-cache overload. We made all writers invalidate both clusters before anything else, warmed the new cluster with fallback-and-copy reads and a pre-copy of hot keys, moved readers per service and per percentage behind flags with shadow reads to compare values, protected the database with monitoring, concurrency limits and coalescing, and finished by keeping the old cluster for a rollback window and then removing the transition code.
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 main risk is invalidation, so first every writer invalidates both clusters for the whole transition; only then do we warm the new cluster, by letting readers that miss on it fall back to the old one and copy the value across and by pre-copying the hottest keys. We move readers service by service and percentage by percentage behind flags, compare values with shadow reads, watch database load with concurrency limits in place, and retire the old cluster and the dual-invalidation code only after the rollback window ends.
Why this question is asked
Moving a cache sounds easier than moving a database, because a cache holds nothing that cannot be rebuilt. That is exactly why cache migrations go wrong: teams switch to an empty cluster and the database collapses under the misses, or they forget that invalidations must reach both clusters and serve stale data for hours. With 600 GB of data, 30 readers and 15 writers, both risks are real. Interviewers ask this scenario to see whether we can sequence a migration so that each step is safe and reversible. In this answer, we will set out the risks, make invalidations reach both clusters, warm the new one, move readers gradually with verification, protect the database, finish cleanly, and choose the first service.
1What Can Go Wrong
Two failures matter. The first is stale data. During the move both clusters hold copies of the same keys. If a writer invalidates only the old cluster, a service already reading the new cluster keeps a stale value; if it invalidates only the new one, a service that has not moved yet, or that rolls back, reads stale data from the old one. Since TTLs on cached data are often hours, that staleness lasts.
The second is a cold-cache overload. If a busy service switches to an empty cluster, its hit ratio drops from perhaps 95 percent to near zero, and the database suddenly receives twenty times its usual reads from that service. If several services switch close together, the database can fall over. The new cluster is also in another network, so each call may take a millisecond or two longer, which matters for services that make many cache calls per request.
2Make Every Writer Invalidate Both Clusters
Before any reader moves, all 15 writer services must invalidate in both clusters. We put this behind a small shared invalidation library or a central invalidation service, so the 15 writers call one function and the dual delete happens in one place. A failure to invalidate the new cluster is retried and logged, because a silent miss there becomes stale data later.
The reason this comes first is ordering. Any value copied into the new cluster before dual invalidation is live could miss an invalidation and stay stale. So we deploy dual invalidation to all writers, confirm through the metric that every writer is calling it, and only then start filling the new cluster.
3Warm the New Cluster Instead of Switching Cold
We warm the new cluster in two ways. The first is fallback with copy: a reader that misses on the new cluster tries the old cluster, and if it finds the key there, returns it and writes it into the new cluster with its remaining TTL, which it reads with PTTL. Only if both miss does it go to the database. So a moved service hits the database no more often than before, and the new cluster fills with exactly the keys that are used.
The second is pre-copying the hottest key prefixes before traffic moves, with a job that scans the old cluster and copies keys with their TTLs, or with the managed service's own migration tool if it offers one, so check your provider. We do not need all 600 GB; most of the hit ratio usually comes from a small fraction of keys. Throughout, we watch the new cluster's hit ratio, including the fallback hits, and only move more traffic when it is close to the old cluster's.
- GET from the new clustermanaged Redis-compatible service
- Found?YesReturn itNoTry the old cluster
- Found in the old cluster?YesCopy to new with remaining TTL, return itNoLoad from the database
- Load from the databasebehind a concurrency limit
- Write to the new clusterwith the normal TTL
5 steps in order. Play them, or step through them one at a time.
4Move Readers Gradually and Verify
We move readers service by service, and within a service by percentage of traffic, for example 1, 10, 50 and 100 percent, with a feature flag that switches back instantly. The fallback means moving back is also safe, because dual invalidation kept the old cluster correct.
To catch inconsistencies we use shadow reads on a sample of requests, say 1 percent: the service reads the key from both clusters, uses the result from the active one, and compares them in the background. A mismatch means an invalidation was missed or a copy was stale, and the metric tells us which keys and which writer to look at before we move more traffic.
5Protect the Database at Every Step
Even with fallback, some misses reach the database, and several services moving in the same week can add up. So we watch database load, connections, CPU and query latency, at every step and pause the rollout if they rise. Each service keeps concurrency limits on its database loads, for example a bulkhead of 20 concurrent loads per instance, plus request coalescing so a hot key that misses is loaded once rather than by every waiting request. If the database comes under pressure, the limits make requests queue or fail fast instead of turning a slowdown into an outage.
| Phase | Action | Watch before continuing |
|---|---|---|
| 1 | Dual invalidation in all 15 writers | invalidate_new_failed near zero |
| 2 | Pre-copy hot prefixes | new cluster memory and copy rate |
| 3 | First service at 1 to 100 percent | hit ratio, shadow-read mismatches, DB load |
| 4 | Remaining services in waves | DB load, latency to the new network |
| 5 | Old cluster kept for rollback | no reads to old cluster for the window |
| 6 | Remove dual invalidation and fallback code | old cluster shut down |
6Finish Cleanly
We stop reading the old cluster only after every reader has moved, and we keep it running, still receiving invalidations, for an agreed rollback window, for example two weeks. Then we turn off fallback reads, shut the old cluster down, and remove the dual-invalidation and fallback code from the shared library and from all services.
That last step is easy to skip and should not be. Transition code that stays behind becomes permanent: someone later wonders why every invalidation is sent twice to a cluster that no longer exists, or a failure in it causes an incident. We put the cleanup in the plan with an owner and a date from the start.
7Follow-up questions
Which service would you move first, and why?
A read-heavy service with a high hit ratio, simple keys and a tolerance for brief staleness, owned by a team that is available to watch it, such as a catalogue or settings reader. It exercises the fallback, warming and shadow reads with real traffic while the impact of any mistake is small. I would not start with the busiest service or one whose cache protects the database from heavy queries, because that is where a cold-cache mistake hurts most; those move last, once the process is proven.
Why copy with the remaining TTL instead of a fresh TTL?
Because the TTL is the bound on staleness. If we copy a value that has five minutes left and give it a fresh hour, we extend the life of data that may already be about to expire for a reason, and any value that slipped past an invalidation lives much longer. Copying the remaining TTL keeps the old cluster's guarantees.
What if the old and new clusters disagree in the shadow reads?
We look at the key's writer: usually a service that was not yet calling the shared invalidation function, or a failed delete that was not retried. We fix that path before moving more traffic, and delete the mismatched keys in both clusters so they reload from the database.
8Conclusion
In this answer, we planned a cache migration around its two real risks, stale data and a cold-cache overload. We made all writers invalidate both clusters before anything else, warmed the new cluster with fallback-and-copy reads and a pre-copy of hot keys, moved readers per service and per percentage behind flags with shadow reads to compare values, protected the database with monitoring, concurrency limits and coalescing, and finished by keeping the old cluster for a rollback window and then removing the transition code.
Open with
I would plan the move around two risks, stale data and a cold cache. Stale data comes from invalidations reaching only one cluster, so step one, before any reader moves, is to make all 15 writers invalidate both clusters through one shared library or service, with retries and a metric for failures.
Then, if they want more
Then I warm the new cluster rather than switching cold. Readers that miss on the new cluster fall back to the old one, and if they find the key they copy it across with its remaining TTL, so the database sees no extra load.
I would also pre-copy the hottest prefixes, since most of the hit ratio comes from a small part of the 600 GB. Readers move service by service and percentage by percentage behind a flag, and I use shadow reads on a small sample to compare values between clusters, which catches any writer that missed an invalidation.
At every step I watch database load and latency to the new network, and services keep concurrency limits and request coalescing on database loads. I would start with a read-heavy, low-risk service.
At the end, I keep the old cluster alive for a rollback window, then shut it down and remove the dual-invalidation and fallback code, with an owner and a date so it does not become permanent.
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 "How do you plan the move so neither stale data nor a cold-cache overload happens during...": https://scrivio-interview-library.netlify.app/architecture/caching-strategies/b4f927c90d/