Quick revision
The short answer
After the restart, the primary loaded its data from disk and then rebuilt the search index by scanning all 20 million keys, and until FT.INFO shows percent_indexed at 1 every query sees only the part indexed so far. A replica maintains its own index from replicated writes, so failing over to a warm replica avoids the rebuild, but this primary had none. The design fix is a replica per primary, smaller shards, failover drills, an application that detects partial indexing and degrades openly, and an honest look at whether a dedicated search engine fits better at this size.
What to remember
In this answer, we saw that the restarted primary loaded its documents and then rebuilt its in-memory index by scanning the keyspace, serving partial results until percent_indexed reached 1, and that a primary without a replica has no way around this. We designed for warm failover with a replica per primary, smaller shards and drills, made the application detect indexing state and degrade visibly, and weighed whether a dedicated search engine should own product search at this size.
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.
After the restart, the primary loaded its data from disk and then rebuilt the search index by scanning all 20 million keys, and until FT.INFO shows percent_indexed at 1 every query sees only the part indexed so far. A replica maintains its own index from replicated writes, so failing over to a warm replica avoids the rebuild, but this primary had none. The design fix is a replica per primary, smaller shards, failover drills, an application that detects partial indexing and degrades openly, and an honest look at whether a dedicated search engine fits better at this size.
Why this question is asked
Partial search results are a quiet failure: no errors, no alerts, just customers who cannot find products for 40 minutes while sales drop. Interviewers ask this scenario to see whether we understand that an in-memory index has to come from somewhere after a restart, that replication helps only if a replica exists and is warm, and whether we design the application to notice degraded search. In this answer, we will recap how the query engine holds its index, follow the restart step by step, design the deployment around warm replicas, add detection and fallback in the application, and weigh Redis against a dedicated search engine.
1A Quick Recap: The Index Lives in Memory
The Redis query engine keeps its indexes in memory, next to the data. When documents are written, the index is updated as part of the write. The documents themselves are persisted by RDB snapshots or the AOF, but the index, depending on version and configuration, may not be persisted in a form that can simply be loaded back. In that case, after Redis loads the documents from disk, the engine rebuilds the index by scanning the keyspace, much like it does when we run FT.CREATE over existing keys. Check how your version persists or rebuilds indexes, because this has changed across releases.
While a background scan runs, the index already answers queries, but only over the documents scanned so far. FT.INFO shows this with indexing set to 1 and percent_indexed between 0 and 1.
2What Happened During the 40 Minutes
The primary restarted and loaded 20 million JSON documents from its RDB or AOF, which itself took a few minutes. It then began accepting commands, and the engine started scanning keys to rebuild idx:product. A search for running shoes at that moment found only the matching products in the part already scanned, perhaps a third of them. Nothing was wrong from Redis's point of view, so no error reached the application.
Because the primary had no replica, there was nothing to fail over to. A Sentinel or cluster setup cannot promote a replica that does not exist, so the only path back to full results was waiting for the scan to finish.
- Primary process restartsno replica to take over
- Load 20 million documents from RDB or AOFminutes; no queries yet
- Start serving commandsindex scan begins
- percent_indexed = 1?YesFull resultsNoQueries return partial results
- About 40 minutes later the scan completes
5 steps in order. Play them, or step through them one at a time.
3Designing for Warm Failover
A replica receives every write the primary receives and updates its own index from those writes, just as the primary does. So at the moment of a failure, the replica already has a complete, current index. If the primary crashes, Sentinel or the cluster promotes the replica within seconds, and search keeps returning full results. The old primary, when it returns, rejoins as a replica; any rebuild it does happens while it is not serving traffic.
So the first rule for search workloads is at least one replica per primary, in a different zone, with automatic failover. The second is to keep shards small enough that any rebuild is short: 20 million documents on one primary is a large unit, while ten shards of 2 million each rebuild in a few minutes, and a rebuild after a double failure is then a smaller incident. The third is to test it: kill a primary under realistic query load and check that results stay complete, and restart a replica to time its rebuild.
| Setup | After primary failure | Search results |
|---|---|---|
| Single primary, no replica | restart, load, rebuild index | partial for tens of minutes |
| Primary plus warm replica | replica promoted in seconds | complete |
| Smaller shards plus replicas | only one small shard affected | complete; rebuilds short |
4Detecting Partial Indexing in the Application
Even with replicas, an index can be incomplete, for example after both copies of a shard were lost. The application should not hide that. A small component polls FT.INFO every few seconds and exposes the state, and the search service uses it.
The fallback can be cached results for popular queries, a reduced category browse, or a clear message that search is temporarily limited. Any of these is better than a page that silently claims there are only three products. The same flag can drive a readiness check so a load balancer prefers healthy shards or regions.
5Is Redis the Right Primary Search Engine Here?
At 20 million products, it is fair to ask. Redis shines when queries are simple filters and lookups and latency must be a millisecond or two. A dedicated search engine such as Elasticsearch or OpenSearch offers richer relevance tuning, language analysers, synonyms, persisted index segments that survive restarts, and mature operational tooling for large indexes. The usual compromise is to keep the dedicated engine as the main product search and use Redis for hot, simple paths such as autocomplete or availability filters. The decision depends on how much relevance work the shop needs and what the team can operate well.
6Follow-up questions
How would you alert on partial indexing?
Export percent_indexed, indexing and num_docs from FT.INFO for every index on every node, and alert when percent_indexed stays below 1 for more than a minute or when num_docs drops well below the expected count. Add a synthetic query with a known number of results, for example a test category of exactly 50 products, and alert when it returns fewer.
Would persistence settings alone have avoided this?
No. Persistence brought the documents back, which is why the scan could run at all. The time to rebuild the index after loading is what hurt, and only a warm replica avoids serving during that time.
Could we block search traffic until indexing completes?
Yes, by failing the readiness check of that shard or returning a degraded response, as above. Whether to block or degrade is a product decision, but either is better than silent partial results.
7Conclusion
In this answer, we saw that the restarted primary loaded its documents and then rebuilt its in-memory index by scanning the keyspace, serving partial results until percent_indexed reached 1, and that a primary without a replica has no way around this. We designed for warm failover with a replica per primary, smaller shards and drills, made the application detect indexing state and degrade visibly, and weighed whether a dedicated search engine should own product search at this size.
Open with
What happened is that after the restart the primary first loaded its 20 million documents from disk and then rebuilt the search index by scanning the keyspace. While that scan runs, the index answers queries over only the documents indexed so far, so we returned partial results for 40 minutes, and FT.INFO showed indexing in progress with percent_indexed below 1.
Then, if they want more
I would check how our version persists or rebuilds indexes, but the shape is the same. A replica would have avoided this, because a replica applies the same writes and maintains its own complete index, so a failover to a warm replica keeps full results. This primary had no replica, so there was nothing to promote.
My design would be at least one replica per primary in another zone with automatic failover, shards small enough that any rebuild takes minutes rather than most of an hour, and regular failover tests under load.
In the application I would poll FT.INFO, expose percent_indexed as a metric, and when it is below 1 fall back to cached popular results or show that search is limited, rather than silently returning partial lists.
And at this size I would also ask whether a dedicated search engine should own product search, with Redis kept for the simple, latency-critical paths.
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 "Explain why this happens, and how you would design the deployment so a restart or...": https://scrivio-interview-library.netlify.app/databases/redis-patterns/a0d89273d9/