Quick revision
The short answer
I would build an inventory from both sides, the Redis deployments (key prefixes and command mix) and the code (client libraries in dependency graphs, searches for lock, idempotency, dedupe and queue patterns), and ask owning teams to classify each use by what losing recent writes would cause: harmless, annoying or harmful. Only harmful uses, those touching money, inventory or duplicate side effects, need change, and they get a durable source of truth or a fencing and idempotency design that tolerates loss, funded as explicit work. A short standard, a design review item, safe platform defaults and failover tests keep new ones from appearing, and the risk is reported in business terms.
What to remember
In this answer, we built an inventory of Redis uses from deployments and code, asked owning teams to classify each by the consequence of losing recent writes, and kept the work to the harmful class. Those uses get a durable source of truth or fencing and idempotency, funded explicitly. A short standard, a review checklist item, safe platform defaults and failover tests stop new risky uses, and the risk is reported in numbers the business can weigh.
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 build an inventory from both sides, the Redis deployments (key prefixes and command mix) and the code (client libraries in dependency graphs, searches for lock, idempotency, dedupe and queue patterns), and ask owning teams to classify each use by what losing recent writes would cause: harmless, annoying or harmful. Only harmful uses, those touching money, inventory or duplicate side effects, need change, and they get a durable source of truth or a fencing and idempotency design that tolerates loss, funded as explicit work. A short standard, a design review item, safe platform defaults and failover tests keep new ones from appearing, and the risk is reported in business terms.
Why this question is asked
After several incidents, the risk review is really asking a question about the whole organisation: where else are we one failover away from the same problem? With 200 services, nobody knows the answer from memory, and asking every team to fix everything would stall product work for months. Interviewers ask this to see whether a leader can turn a vague worry into a bounded, prioritised programme. In this answer, we will recap why Redis can lose acknowledged writes, build the inventory, classify what we find, decide what must change, and put in place the guardrails that stop new risky uses.
1A Quick Recap of Why This Risk Exists
Redis replicates asynchronously, so a write acknowledged by a primary can be lost when a replica is promoted after a failure or a partition. For a cache, that is harmless: the next read reloads the value. But teams also use Redis for things where a lost write changes behaviour. A lock that disappears lets two workers run the same job. A deduplication key that disappears lets a message be processed twice. A counter that resets lets a limit be exceeded. A queue item that disappears means work never happens.
These dependencies are silent because they work perfectly until a failover, which may happen once a year. That is why a deliberate search is needed.
2Building the Inventory From Both Sides
We look from the infrastructure side and from the code side, because each finds things the other misses. On the infrastructure side, for every Redis deployment we sample key names to find prefixes, and we read the command statistics to see what kinds of work it does: SET with NX and PX suggests locks, INCR suggests counters, LPUSH with BRPOP or XADD suggests queues. On the code side, we use the dependency graphs from the build system to list every service that includes Lettuce, Jedis, Redisson or Spring Data Redis, and we search code for patterns such as tryLock, setIfAbsent, idempotency, dedupe and RLock.
The output of both searches is a list of candidate uses, each with an owning team. We then send each team a short form asking what the use is and what happens if Redis loses the last few seconds of writes. The teams know their services better than any search, and asking them also spreads awareness of the problem.
3Classifying by the Consequence of Loss
The classification is by consequence, not by data structure, because the same SET can be a harmless cache entry in one service and a payment lock in another. Three classes are enough to make decisions.
| Class | Examples | Action |
|---|---|---|
| Harmless | caches, precomputed views | none |
| Annoying | sessions, rate limits, feature counters | document; accept the loss |
| Harmful | money, inventory, locks guarding side effects, dedupe of external calls | change the design |
Only the harmful class needs work. In most organisations it is a small fraction of the total, which is what makes the programme affordable. Annoying uses still get documented, so the next incident review does not rediscover them.
4Deciding What Must Change
For each harmful use, there are two acceptable designs. The first moves the truth into a durable store: a database row with a unique constraint for idempotency, a database table or a durable broker for queues, a database counter for inventory. Redis can stay in front for speed. The second keeps Redis but makes the use tolerate loss: a lock that issues a fencing token, an increasing number that the protected resource checks so that a stale holder's writes are refused, together with idempotent operations, so a lost lock or key causes a retry rather than damage.
This work must be funded explicitly. If we add it to feature backlogs with no time attached, it will wait until the next incident. I would agree a budget with product leadership, for example a fixed share of each affected team's capacity for one or two quarters, and track the items in one place.
5Keeping New Dependencies From Appearing
Fixing today's list is half the job; the other half is making sure the list stays short. Four guardrails work together. A one-page engineering standard states that Redis may hold data whose loss is harmless or annoying, and that harmful uses need a durable backstop. A design review checklist item asks, for any new Redis use, what happens if the last seconds of writes are lost. The platform team ships safe defaults, such as a lock library that issues fencing tokens backed by a durable store, so the easy path is also the right one. And regular failover tests in staging kill primaries under load and check the business outcomes, which exposes assumptions that nobody wrote down.
- Find the usekey prefixes, command stats, code search
- Owning team describes itwhat does losing recent writes cause?
- Harmful (money, inventory, side effects)?YesPlan a durable store or fencing + idempotencyNoDocument it and move on
- Fund and track the changeexplicit capacity, one tracking list
- Prove it in a failover testkill a primary under load, check outcomes
5 steps in order. Play them, or step through them one at a time.
6Reporting the Risk in Business Terms
The risk review and the executives will not act on the phrase asynchronous replication. They act on numbers such as: in a failover, the order service could double-ship up to 200 orders, and the payment flow could cause up to 50 duplicate charges. We can estimate these from write rates and the replication lag seen in past failovers. Put next to the cost of the work, those numbers let leadership weigh the investment against the cost of the next incident.
7Follow-up questions
How would you prioritise if 30 harmful uses are found?
By expected damage and ease of fixing. For each use I would estimate the cost of one failover, in money, customer impact and regulatory exposure, and how likely a failover is for that deployment. Money and inventory flows with external side effects come first, especially when the fix is small, such as adding a unique constraint. Then I would group uses that share a fix, for example all services using the same home-grown lock library, so one platform change removes many items at once. Low-damage items wait, documented.
What is a fencing token, and why does it help?
It is a number that increases every time a lock is granted. The holder sends it with each write to the protected resource, and the resource rejects any write with a lower number than one it has already seen. So if a lock is lost in a failover and a second worker takes it, the first worker's late writes are refused. It needs the resource, often a database, to store and compare the number.
Should we ban Redis for these uses altogether?
No. A ban pushes teams to work around it and loses Redis's speed where it is safe. The standard should allow any use whose loss is harmless or annoying, and require a durable backstop only for harmful ones.
8Conclusion
In this answer, we built an inventory of Redis uses from deployments and code, asked owning teams to classify each by the consequence of losing recent writes, and kept the work to the harmful class. Those uses get a durable source of truth or fencing and idempotency, funded explicitly. A short standard, a review checklist item, safe platform defaults and failover tests stop new risky uses, and the risk is reported in numbers the business can weigh.
Open with
I would run it as a bounded programme with four steps. First, inventory from both sides. On the infrastructure side, sample key prefixes and read the command mix of every Redis deployment, since NX locks, INCR counters and list or stream queues each leave a trace.
Then, if they want more
On the code side, use the dependency graphs to find every service with a Redis client and search for lock, idempotency, dedupe and queue patterns. Then ask the owning teams to describe each use and what losing the last few seconds of writes would do.
Second, classify by consequence: harmless like caches, annoying like sessions and rate limits, or harmful, meaning money, inventory or duplicate side effects. Only the harmful class needs action, and it is usually small.
Third, for each harmful use, require a durable source of truth, such as a database unique constraint for idempotency, or a design with fencing tokens and idempotency that tolerates loss, and fund that work explicitly rather than adding it to feature backlogs.
Fourth, prevent drift: a short engineering standard, a design review question, safe platform defaults like a lock library with fencing tokens, and failover tests in staging that expose hidden assumptions. And I would report the risk in business terms, such as how many duplicate charges a failover could cause.
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 "As the senior technical leader, how do you find these dependencies, decide what must...": https://scrivio-interview-library.netlify.app/databases/redis-scaling/c93e1b0d85/