System Design blueprint · Cloud infrastructure
Distributed cache cluster
A Redis-like sharded cache that routes keys with consistent hashing, replicates each shard, evicts by LRU/LFU and TTL, and absorbs hot keys and stampedes. It must never serve data past its intended staleness, and must never let a topology change or mass expiry push full traffic onto the database.
- Steps
- 9
- Subjective questions
- 33
- Objective questions
- 33
The problem and the outcome
Problem: A single cache node cannot hold the working set or survive its own failure. Naive modulo sharding remaps almost every key when a node is added, which floods the database with misses.
Outcome: Reads are served from memory across many nodes with predictable latency. Nodes can be added, lost or replaced while only a small, controlled fraction of keys move, and the database sees a bounded load.
Architecture
How it works, step by step
- The app calls the smart client, which hashes the key onto a fixed slot space (Redis Cluster uses CRC16 mod 16384) and looks up the owning node in its cached slot map. Virtual nodes or slots keep load even and let ownership move in small units.
- For keys flagged hot by sampled request counts, the client serves from a small in-process L1 with a very short TTL, or reads from replicas, so one shard is not saturated by a single key.
- The request goes to the shard primary. A hit returns immediately; a stale-slot error (MOVED/ASK style redirect) makes the client refresh its slot map and retry.
- On a miss, single-flight coalescing lets only one caller per key load from the database while others wait or get a stale value; the fill uses a TTL with random jitter so keys do not expire together.
- Writes use write-through (update database, then cache or invalidate) for correctness-sensitive data, or write-back (cache first, durable queue flushes in batches) where write volume matters more than instant durability.
- Each primary streams changes asynchronously to replicas. A quorum of monitors detects a dead primary, promotes the most up-to-date replica, and bumps the config epoch so stale owners are fenced off.
- Under memory limits the node evicts using approximated LRU or LFU by sampling keys, and expires TTL keys both lazily on access and through a periodic active sweep.
- To add a node, the rebalancer moves a few slots at a time, copying keys before switching ownership and redirecting in-flight requests, so only the moved fraction misses and the database is never hit all at once.
- Telemetry tracks hit ratio, latency, evictions, replication lag and migration progress per shard, and alerts before a hot shard or falling hit ratio becomes a database outage.
Tech stack
- Redis Cluster or Valkey
- Memcached with client-side consistent hashing
- Redis Sentinel or cluster-bus failover
- Envoy or twemproxy-style cache proxy
- Kafka for write-back and invalidation events
- Prometheus and Grafana
- Go or Java client with single-flight
Key design decisions
- Fixed hash slots with an owner map instead of pure ring hashing, so rebalancing and failover move named units and are easy to reason about.
- Cache-aside with delete-on-write as the default; write-back only for data that tolerates loss of the unflushed tail.
- Asynchronous replication for latency, accepting that acknowledged writes can be lost on failover; use WAIT-style acknowledgements only where needed.
- LFU for skewed, stable workloads and LRU for recency-driven ones, chosen per cluster rather than globally.
- Smart client routing to avoid an extra network hop, with a proxy tier only when clients cannot be upgraded.
Common mistakes
- Using hash(key) mod N, so adding one node remaps almost every key and causes a mass miss storm.
- Setting the same TTL on keys loaded together, causing synchronized expiry and a stampede on the database.
- Ignoring hot keys; a single viral key can saturate one shard while the rest of the cluster is idle.
- Updating the cache before the database or racing set-after-delete, leaving stale values with long TTLs.
- Promoting a replica without fencing the old primary, leading to split-brain writes after a network partition.
What to measure
- Cache hit ratio per keyspace and per shard
- p50/p99 get and set latency
- Eviction and expiry rate versus memory usage
- Replication lag and failover detection-to-promotion time
- Database QPS during deploys, failovers and rebalances
Most-asked interview questions
Subjective questions 33
1How would you add a node to a cache cluster without causing a flood of misses?Asked almost every time
First, I never use modulo hashing; I map keys to a fixed set of slots or virtual nodes, so a new node takes only about one over N plus one of the keyspace. Then I migrate gradually: the rebalancer picks a few slots, copies their keys to the new node while the old owner still serves them, and only then flips ownership in the config with a new epoch. During the move, a request for a key that has already moved gets a redirect, so the client follows it rather than missing. I throttle migration speed, watch database QPS and hit ratio, and pause if misses rise. The net effect is that users barely notice, and the database sees a small, bounded bump instead of a cold-cache spike.
2What is a cache stampede and how do you prevent it?Asked almost every time
A stampede happens when a popular key expires or is evicted and many concurrent requests miss at once, all hitting the database to rebuild the same value. I use layered defences. Request coalescing, or single-flight, lets only one caller per key go to the database while the others wait for its result. A short lease or lock in the cache does the same across many app instances. I add random jitter to TTLs so keys loaded together do not expire together. For very hot keys I refresh early, either probabilistically as expiry nears or with a background refresher, and allow serving a slightly stale value while the rebuild runs. Together these keep database load roughly constant even under heavy traffic.
3Walk me through the full read path for a single GET in this cache cluster.Asked almost every time
The app calls the smart client. The client hashes the key with CRC16 mod 16384 to get a slot and looks up the owner in its cached slot map. If the key is flagged hot, it first checks a small in-process L1 with a very short TTL, or reads from a replica. Otherwise it sends the GET to the slot's primary. A hit returns at once. A MOVED redirect makes the client refresh its slot map and retry. An ASK redirect sends a one-off retry to the importing node. On a miss, single-flight lets one caller per key load from the database, write the value with a jittered TTL, and serve the callers that were waiting. Throughout, the client records latency and the hit or miss for telemetry.
4What is the difference between a MOVED and an ASK redirect, and how should a client react to each?Asked almost every time
MOVED means the slot now belongs to another node permanently. The client should update its slot map, either for that slot or by refreshing the whole map with CLUSTER SHARDS, and then retry on the new owner. ASK appears only during a slot migration. It means this particular key has already moved to the importing node, but the slot itself has not been reassigned yet. The client sends ASKING followed by the command to the target node, just once, and does not change its slot map. Later requests for that slot still go to the old owner until migration ends and a MOVED shows up. If a client wrongly updates its map on ASK, it can send requests for keys that have not moved to the importing node, which will just redirect them back.
5The requirement says the cache must never serve data past its intended staleness. How do you actually guarantee that?Asked almost every time
First, make the bound explicit for each data type, for example 30 seconds for a product price. Every cached value gets a TTL no longer than that bound, and jitter only shortens the TTL, never lengthens it. The L1 TTL must also fit within the bound, counting time spent on replicas, so total staleness equals L1 TTL plus replication lag plus the shared cache TTL. Next, on writes, invalidate rather than wait for expiry, and use change-data-capture from the database binlog as a backstop for missed deletes. If you serve stale values during a stampede, store the original load time with the value and refuse anything older than the bound. Finally, alert on replication lag so replica reads cannot quietly break the budget.
6How do you detect hot keys and stop one key from saturating a shard?Asked almost every time
For detection, the client or a proxy samples requests and counts keys over a sliding window, for example with a count-min sketch, and marks keys above a threshold as hot. With an LFU policy, server-side tools such as redis-cli --hotkeys also work, but client sampling responds faster. For mitigation, hot keys are served from an in-process L1 with a TTL of a second or two, which removes most of the traffic before it reaches the network. For heavy reads you can also spread load across replicas, or split the key into N copies such as key#0 to key#7 placed on different slots, with clients picking a copy at random. Writes to a split key have to update or invalidate every copy. Hot status should be dynamic and expire on its own.
7In cache-aside, why do teams delete the cache entry after a database write instead of updating it, and what race remains?Asked almost every time
If two writers update the database and then each sets the cache, their cache writes can land in the opposite order to their database commits. The cache then holds the older value until TTL. Deleting the entry avoids that, because the next reader loads whatever is current. One race remains. A reader misses, reads the old value from the database, and pauses. Meanwhile a writer commits and deletes the key. The reader then writes the old value back. This is uncommon but real. Ways to reduce it include leases, where the server hands out a token on a miss and rejects the fill if a delete happened in between, version-checked sets, a short delayed second delete, and a TTL that caps how long the damage can last.
8A shard primary dies. Walk me through failover and tell me what data can be lost.Asked almost every time
Other nodes stop getting heartbeats. After the node timeout they mark the primary as possibly failed, and once a majority of primaries agree, it is marked failed. Its replicas wait a short delay based on replication offset, so the most up-to-date replica usually asks first, and they request votes. A replica that wins a majority of primaries is promoted, takes a higher config epoch, and announces the new ownership. Clients get MOVED replies or refresh their maps and then follow the new primary. Because replication is asynchronous, writes the old primary acknowledged but never sent to the replica are lost. For a cache that loss is usually fine. For write-back data it is not, which is why write-back needs a durable queue outside the cache.
9What happens if the whole cache cluster restarts cold or a huge batch of keys expires together, and how do you protect the database?Asked almost every time
That is a cache avalanche. Hit ratio drops to near zero and the full read load hits the database. Prevention starts with jittered TTLs, so keys loaded together do not expire together, and with replicas and persistence so one failure does not empty the cache. For the cold-start case, warm the cache from an RDB snapshot or by replaying a list of hot keys before taking traffic, and add nodes back gradually. At the database edge, put a concurrency limiter or circuit breaker in front of loads. Requests beyond the database's safe capacity get a stale value, a default, or a fast error rather than queuing. Single-flight still applies per key. The goal is to degrade gracefully, never to overload the database.
10When would you choose write-through over write-back caching?Very often asked
Write-through updates the database synchronously as part of the write, so the cache and the source of truth stay aligned and an acknowledged write is durable. I pick it, or cache-aside with invalidation, for money, inventory, permissions and anything where losing or reordering a write is unacceptable. Write-back acknowledges after updating the cache and flushes to the database later in batches. It gives lower write latency and absorbs bursts, which suits counters, view stats or session activity. The cost is that a node crash can lose unflushed writes, and reads from other systems hitting the database see old data. If I use write-back, I put writes on a durable log and make the flush idempotent, so the loss window is small and replay is safe.
11What is split-brain in a cache cluster, and how does the config epoch fence off a stale primary?Very often asked
Split-brain happens when a network partition leaves the old primary running on the minority side while the majority side promotes a replica. For a while, two nodes believe they own the same slots. Redis Cluster limits this in two ways. A primary that cannot reach a majority stops accepting writes after the node timeout, which caps how long it can diverge. Every ownership change also carries a config epoch, and when nodes see conflicting claims, the higher epoch wins. When the partition heals, the old primary sees the higher epoch, steps down to become a replica, and throws away the writes it took during the split. Clients that reach it get redirected. The remaining risk is the writes accepted during that short window.
12How do you protect the database from cache penetration, where requests ask for keys that do not exist?Very often asked
Missing keys always miss, so an attacker or a bug can push every one of these requests to the database. The first defence is negative caching. When the database returns nothing, cache a placeholder with a short TTL, and keep it short so a record created later shows up quickly. For large keyspaces, put a Bloom filter of valid IDs in front. A Bloom filter never gives a false negative, so a 'not present' answer can be rejected without touching the database. It does give occasional false positives, which simply go through to the database as normal. Add input validation such as ID format and range checks, plus per-client rate limits. Also alert on a rise in misses that return empty results.
13Size a cluster for 200 million keys averaging 500 bytes and 1 million operations per second. State your assumptions.Very often asked
Raw data is 200 million times 500 bytes, about 100 GB. Per-key overhead from the key itself, dictionary entries and allocator waste is significant for small values, so I would assume 1.5 to 2 times raw, giving about 150 to 200 GB. Add headroom for fragmentation and copy-on-write during snapshots, and aim for around 60 to 70 percent memory use. That points to roughly 300 GB of primary memory, or about 12 shards of 25 GB. For throughput, I would benchmark one node with our value sizes and pipelining rather than assume a number. If a node safely handles about 100k ops per second, 1 million needs at least 10 primaries, so 12 works with margin. One replica per primary doubles memory. I would validate this with a load test.
14Why map keys to a fixed slot space instead of hashing them directly onto a ring of nodes?Very often asked
A fixed slot space separates key placement from node placement. The key-to-slot mapping never changes. Only slot ownership changes, and that is a small, explicit table that clients can cache and nodes can gossip. Moving load means reassigning specific slots, which is easy to reason about, migrate one at a time, and monitor. Balance is controlled directly, because you assign equal slot counts or move individual hot slots, instead of depending on where random virtual node points happen to fall. It also makes redirects simple, since a node knows exactly which slots it serves. The trade-offs are a fixed upper limit on how finely data can be split, 16384 in Redis Cluster, and the need to run something that decides slot assignment.
15How do multi-key operations work in a sharded cache, and what are the pitfalls of hash tags?Very often asked
Commands such as MGET, MULTI/EXEC transactions or Lua scripts that touch several keys only work when all keys hash to the same slot. Otherwise the server returns a CROSSSLOT error. Hash tags solve this. If a key contains braces, only the text inside them is hashed, so user:{42}:cart and user:{42}:profile land together. The pitfall is skew. If the tag has low cardinality, such as a tenant ID with one giant tenant, a whole tenant's data sits on one slot, creating hot shards and slots too large to migrate quickly. Use tags only for small, naturally grouped data. For wider reads, let the client split the keys by slot and send the requests in parallel instead of forcing everything onto one slot.
16What consistency trade-offs come with reading from replicas?Very often asked
Replicas trail the primary because replication is asynchronous, so a replica read can return a value that was just overwritten or deleted. That breaks read-your-writes. A user updates a profile, refreshes, and sees the old version. It also adds replication lag to the staleness budget. In Redis Cluster a client has to send READONLY on the replica connection to read there. I would use replica reads only for hot, read-heavy keys that tolerate a little staleness, monitor replication offset lag per replica, and have clients stop using a replica whose lag goes above the budget. For keys that need read-your-writes, route the writer's own reads to the primary for a short window after a write, or keep them on primary only.
17What is the big key problem and how do you handle it?Very often asked
A big key is a single value or collection that is very large, such as a multi-megabyte string or a hash with millions of fields. Command execution is effectively single-threaded per node, so reading, deleting, expiring or migrating such a key can block every other client on that shard and cause latency spikes. It also skews memory and network use and slows slot migration. To handle it, find big keys with scans such as redis-cli --bigkeys or MEMORY USAGE sampling, and set size limits in client libraries. Split large collections into buckets by sub-key hash, and paginate with HSCAN or SSCAN rather than full reads. Use UNLINK instead of DEL and enable lazy-free options so large frees happen in the background.
18In write-back mode, what happens if a node dies before flushing, and how would you design the flush path?Very often asked
If the cache is the only place holding dirty writes, losing the primary loses them, because replication is asynchronous. So write-back needs the write to be durable somewhere before the client gets an acknowledgment. Usually that means appending to a replicated log such as Kafka, or a Redis Stream with AOF fsync and replicas plus WAIT, and the cache update happens alongside. A flusher consumes the log in batches and applies idempotent upserts keyed by entity and version, so replays after a crash are safe. It commits offsets only after the database confirms. Monitor consumer lag as the measure of durability debt, and apply backpressure if it grows. Reads during the delay come from the cache, which is the newest copy.
19How do you keep the in-process L1 cache from serving stale data?Very often asked
The simplest control is a very short TTL, a second or two, kept inside the staleness budget, and only for keys flagged hot. That bounds staleness without any coordination. For tighter freshness, Redis server-assisted client-side caching helps. With CLIENT TRACKING, the server remembers which keys a client has read, or which prefixes in broadcast mode, and pushes an invalidation message when they change. On reconnect or a lost invalidation channel, the client must flush its whole L1, because it cannot know what it missed. Cap L1 by entry count or memory so it cannot hurt the application's heap. Never put sensitive per-user data in a shared process cache without scoping it by user.
20Single-flight coalesces requests within one process. What about 500 app servers all missing the same key?Very often asked
Local single-flight cuts it to one database load per server per key, so up to 500 loads, which may still be too many for a hot key. To coordinate across servers, use a short lock in the cache itself, SET key:lock token NX PX with a timeout of a few seconds. The winner loads and fills the value. The others briefly poll, or better, serve the previous value kept with a soft expiry. The lock must expire in case the winner crashes, and should be released only if the token matches. Memcache-style leases do the same thing and also stop stale sets. Combine this with early refresh so hot keys rarely miss in the first place. These locks are about efficiency, not correctness.
21How would you secure this cache cluster?Very often asked
First, network isolation. Nodes live in private subnets, and security groups allow only app servers and other nodes on the client port and the cluster bus port. Never expose them to the internet. Turn on TLS for client and replication traffic, including the bus where supported. Use ACLs, available since Redis 6, so each service has its own user limited to its key prefixes and needed commands. Block dangerous commands such as FLUSHALL, KEYS, CONFIG and DEBUG for application users. Keep passwords in a secrets manager and rotate them. Keep protected mode on and disable the default user. Encrypt RDB and AOF files at rest. Log admin commands and authentication failures, and patch quickly, since remote-execution vulnerabilities have affected exposed instances.
22Which metrics and alerts would you set up for this cluster, and why?Very often asked
Per shard I track hit ratio, p99 latency, ops per second, memory used against maxmemory, evicted and expired keys, connected clients, CPU, network bytes, replication offset lag, and migration progress. From the client side I track miss rate per key prefix, MOVED and ASK rates, timeouts, and database load caused by misses. Alerts should catch trouble before the database feels it. Examples are a hit ratio falling below baseline for several minutes, one shard's traffic or CPU far above its peers, which signals a hot key, a rising eviction rate, replication lag above the staleness budget, memory above about 80 percent, and a migration that stalls. Dashboards should put database query rate next to the cache hit ratio so the link is obvious.
23Why does the cache expire TTL keys both lazily and with an active sweep?Often asked
Lazy expiry checks the TTL when a key is accessed and deletes it if it has expired, so an expired value is never returned and no background work is needed. On its own, though, keys that are never read again would sit in memory forever. The active sweep handles that. Several times a second, Redis samples keys from the set that have TTLs, deletes the expired ones, and repeats while a large share of the sample turns out expired, within a time budget so latency stays steady. Together they give correctness from the lazy check and memory reclamation from the sweep. Replicas do not expire keys on their own timer. They wait for deletes from the primary, though a read on a replica still reports an expired key as missing.
24Which maxmemory policy would you choose for this cache and why?Often asked
For a pure cache where every key can be rebuilt from the database, I would pick allkeys-lfu or allkeys-lru. LFU keeps steady popular keys better when there are scans or one-off bursts. LRU suits workloads where recent use predicts the next access. volatile-* policies only evict keys that have a TTL, so if some keys lack one, the node can fill up and start rejecting writes. They make sense only when the same instance also holds keys that must never be evicted, which I would rather put on a separate cluster. noeviction is wrong for a cache, because writes fail with an out-of-memory error once memory is full. Whatever the choice, watch the eviction rate, because steady evictions of useful keys mean the cluster is too small.
25Compare probabilistic early refresh with lock-based stampede protection.Often asked
Lock-based protection reacts after the miss. One caller refreshes while the others wait or get a stale value, which adds a lock round trip and some waiting. Probabilistic early refresh, as in the XFetch approach, acts before expiry. On each read, a caller decides at random to recompute, with a probability that rises as the TTL approaches zero and with how long recomputation takes. Busy keys get refreshed by one caller just before expiry, so they effectively never miss, and no lock is needed. It needs the stored value to carry its compute time and expiry, and it may cause a few duplicate refreshes. In practice I combine them: early refresh for hot keys and a lock or single-flight as a backstop for real misses.
26Should a cache cluster use persistence such as RDB or AOF?Often asked
For a pure cache, the database is the source of truth, so persistence exists only to avoid cold starts. RDB snapshots are a good fit. A restarted node loads a recent snapshot and comes back mostly warm, which protects the database. The cost is forking: copy-on-write can use up to the memory of pages changed during the snapshot, so you need headroom, and the fork itself can briefly stall large instances. AOF with fsync is for data you cannot lose, such as a write-back queue, and adds disk I/O and rewrite overhead. Without persistence, a node that restarts empty and is still a primary could replicate an empty dataset to its replicas, so either enable persistence or make sure restarted nodes come back as replicas.
27What privacy concerns arise when caching personal data, and how do you address them?Often asked
Caches create extra copies of personal data, often outside the database's access controls and deletion processes. Under India's DPDP Act and similar laws, a deletion or correction request has to reach the cache too. So user-data keys need a predictable naming scheme, say user:{id}:*, that a deletion job can invalidate, plus a TTL so missed copies age out. Cache only the fields needed, and keep sensitive identifiers such as Aadhaar or card numbers out of it, or tokenize them. Separate tenants with ACL key prefixes or separate clusters. Encrypt snapshots, and restrict who can run MONITOR or read RDB files, since both expose values. Logs and telemetry should record key patterns, not values or raw user IDs.
28Why replicate asynchronously instead of synchronously, and what does WAIT give you?Often asked
Asynchronous replication keeps write latency at a single local operation. The primary acknowledges right away and streams changes in the background, which suits a latency-focused cache. Synchronous replication would add a network round trip to every write and couple primary availability to replica health. The cost is that acknowledged writes can be lost on failover. WAIT numreplicas timeout lets a client block until that many replicas have acknowledged its earlier writes, which lowers the chance of loss for selected operations. It does not give strong consistency. A failover can still promote a replica that did not receive the write, and WAIT does not roll back on timeout. Use it for important write-back records, not as a consensus protocol.
29How should a smart client maintain its slot map without overloading the cluster?Often asked
At startup the client fetches the topology from a seed node with CLUSTER SHARDS, or the older CLUSTER SLOTS, and caches it. It refreshes when it receives MOVED, when a connection fails, and on a slow periodic timer as a safety net. The risk is a refresh storm. During a failover, thousands of clients all get errors and all fetch topology at once. To prevent that, combine concurrent refreshes in each client so only one request is in flight, rate-limit refreshes to something like once per second, add jitter, and spread topology queries across several nodes. A single MOVED can update just that slot right away while a full refresh runs in the background. ASK never triggers a refresh.
30How would you extend this design across multiple regions?Often asked
Usually each region runs its own independent cache cluster in front of its local database replica, because cross-region round trips would undo the latency benefit. The hard part is invalidation. A write in one region must invalidate cached copies everywhere. The common way is to drive invalidation from the database's change stream, so each region deletes keys after its local database replica has applied the change. That ordering avoids refilling from a lagging replica. The staleness budget then includes cross-region replication lag. Active-active cache replication with conflict resolution exists in some commercial products, but for a cache, independent clusters plus change-data-capture invalidation is simpler. Watch for one region's outage shifting its traffic onto another region's cold cache.
31How do you safely remove a node or replace a failed one?Often asked
To remove a primary, first move all its slots to other primaries in small batches, using the same copy-then-switch migration as when adding a node, and watch hit ratio and database load as it goes. Once it owns no slots, move its replicas elsewhere and run CLUSTER FORGET on every node so the node is not gossiped back in. To replace a failed primary, rely on automatic failover first, then add a fresh node as a replica of the new primary so redundancy is restored. If a shard has lost all replicas, its data is gone, and the slots must be reassigned and rewarmed carefully. Never remove several nodes at once if the remaining memory cannot hold the working set.
32Would you build this on Redis or Memcached, and why?Often asked
Memcached is simple and multi-threaded. It is very efficient for plain key-value strings, and sharding is done entirely in the client. It has no built-in replication, persistence or cluster-managed failover, so losing a node means losing its keys and taking a miss spike. Redis, or the open-source fork Valkey, has data structures, replication, cluster mode with slots and failover, Lua scripting, server-assisted client caching, and ACLs, which match this design's needs: replicated shards, redirects during migration, and atomic lock primitives. Memcached is a reasonable choice for a large, simple, read-heavy cache where losing a node is acceptable. For the requirements here I would choose Redis or Valkey, and check licensing and managed-service options for the organisation.
33What alternatives to ring-based consistent hashing exist, and when would you use them?Sometimes asked
Rendezvous hashing, also called highest random weight, scores each key against every node and picks the highest. It needs no ring or virtual nodes, balances well, and moves only the keys of a node that joins or leaves, but lookup cost grows with node count. Jump consistent hash maps a key to one of N numbered buckets with almost no memory and very even balance, but it only handles adding or removing the last bucket, so it suits numbered shards rather than arbitrary nodes. Maglev hashing builds a lookup table for fast, even mapping and is common in load balancers. For a cache with uneven nodes and planned migrations, an explicit slot table is usually the most practical choice.
Objective questions 33
1Why do consistent hashing schemes use many virtual nodes per physical node?Asked almost every time
Why: With few points per node the ring is uneven; many virtual nodes smooth the distribution and make the keys moved during a change come from many nodes rather than one neighbour.
2How many hash slots does Redis Cluster divide the keyspace into?Asked almost every time
Why: Redis Cluster maps every key to one of 16384 slots and assigns those slots to primaries.
3For the key order:{user42}:items, what does Redis Cluster hash to find the slot?Asked almost every time
Why: When a key contains a non-empty {...} section, only the text inside the first pair of braces is hashed.
4During slot migration a client receives an ASK redirect. What should it do?Asked almost every time
Why: ASK is a one-off redirect for a slot that is still migrating, so the slot map stays unchanged.
5By default, how does a Redis primary replicate writes to its replicas?Asked almost every time
Why: The primary acknowledges the client first and streams changes to replicas in the background.
6Why add random jitter to cache TTLs?Asked almost every time
Why: Jitter prevents keys loaded together from expiring together and hitting the database all at once.
7After a failover with asynchronous replication, what can happen to writes the old primary acknowledged?Asked almost every time
Why: Async replication means the acknowledgment comes before replication, so the last moments of writes can be lost.
8In cache-aside with concurrent writers, why is deleting the cache key after the database commit usually safer than setting the new value?Asked almost every time
Why: Invalidation lets the next reader load the current committed value, so set ordering stops mattering.
9The hit ratio drops sharply while database QPS rises on one dashboard. What is the most likely immediate concern?Asked almost every time
Why: A falling hit ratio sends more load directly to the database, so it should trigger an alert before the database fails.
10In a cluster of N nodes using consistent hashing, roughly what fraction of keys move when one node is added?Very often asked
Why: The new node takes over only its share of the ring, about 1/(N+1) of the keyspace, while modulo hashing would remap nearly all keys.
11How does Redis implement its LRU and LFU eviction policies?Very often asked
Why: Redis samples a configurable number of keys and evicts the best candidate, approximating LRU or LFU with little memory overhead; only the volatile-* policies restrict eviction to keys with a TTL.
12Which hash function does Redis Cluster use to compute a key's slot?Very often asked
Why: The slot is CRC16 of the key, or of its hash tag, modulo 16384.
13What does a MOVED reply indicate?Very often asked
Why: MOVED signals a lasting ownership change, so the client refreshes its slot mapping.
14What happens when an MGET in Redis Cluster includes keys that hash to different slots?Very often asked
Why: Multi-key commands require all keys to be in the same slot, otherwise the server rejects them with CROSSSLOT.
15Which statement about the WAIT command is correct?Very often asked
Why: WAIT lowers the risk of data loss but is not consensus, since a replica that missed the write can still be promoted.
16Briefly caching a placeholder for a key that does not exist in the database mainly defends against what?Very often asked
Why: Negative caching stops repeated lookups of missing keys from always reaching the database.
17With maxmemory-policy set to noeviction, what happens when memory is full?Very often asked
Why: noeviction refuses writes that need memory and returns an out-of-memory error.
18What is the main purpose of the config epoch in failover?Very often asked
Why: A newly promoted replica takes a higher epoch, so after a partition the old primary sees it, steps down, and drops its writes.
19What does single-flight request coalescing achieve on a cache miss?Very often asked
Why: Coalescing turns N simultaneous loads of the same key into one load.
20One product key receives a large share of all reads and saturates its shard. Which mitigation is most effective?Very often asked
Why: L1 caching and key splitting spread or absorb the load instead of sending it all to one primary.
21Roughly how much raw value data do 100 million keys at 1 KB each represent, before overhead?Very often asked
Why: 100,000,000 times 1 KB is about 100 GB, and real memory use is higher once per-key overhead and fragmentation are added.
22Which is the best way to restrict an application to its own key prefix and a safe set of commands?Very often asked
Why: Redis ACLs, available since version 6, control per-user command categories and key patterns.
23While one slot is being moved to a new node, which keys can see extra misses or redirects?Very often asked
Why: Moving slots a few at a time limits disruption to the fraction of data in those slots.
24A Bloom filter of valid IDs is placed in front of the cache. Which property makes it safe to reject requests?Often asked
Why: If the filter says an ID is absent, it is definitely absent, while false positives just fall through to normal lookups.
25Under volatile-lru, which keys can be evicted?Often asked
Why: volatile-* policies only consider keys with an expiry, so a cache full of keys without TTLs can fill up.
26Why is lazy expiry alone not enough?Often asked
Why: The active sweep reclaims memory held by expired keys that no client reads again.
27What must a client send on a connection to a replica before it can read from it in Redis Cluster?Often asked
Why: Without READONLY, a replica redirects reads to its primary with MOVED.
28In Redis Cluster, what does a primary on the minority side of a partition do?Often asked
Why: This caps how long it can diverge from the majority side, which may have promoted a replica.
29How does probabilistic early expiration (the XFetch approach) prevent stampedes?Often asked
Why: Spreading refresh decisions out over time means hot keys are renewed before they expire, without locks.
30Why does an RDB snapshot need spare memory on the node?Often asked
Why: Under heavy writes, copy-on-write can come close to doubling memory for the pages that change.
31Which command frees a very large key without blocking the server while memory is reclaimed?Often asked
Why: UNLINK removes the key from the keyspace right away and frees its memory in a background thread.
32Which Redis feature lets the server push invalidation messages for keys a client has cached locally?Often asked
Why: With tracking turned on, the server remembers which keys a client read and notifies it when they change.
33By default, which port does the Redis Cluster bus use?Sometimes asked
Why: Nodes gossip and coordinate failover over the client port plus 10000, for example 16379, so firewalls must allow it.
Track your progress through every blueprint in your dashboard.
Start learning