Caching medium
In a cluster using Consistent Hashing, you add a new node. What portion of keys are remapped (invalidated)?
- A Almost all keys (proportionally N/N+1) are remapped to new servers, leading to a massive, system-wide cache miss spike.
- B None of the keys are remapped; instead, every active key is duplicated across the entire cluster to ensure high availability.
- C Only a small fraction (roughly 1/N) of total keys are re-mapped to the new node, minimizing the impact on the hit ratio.
- D Keys are permanently assigned to their original nodes and are only remapped if they reach their expiration timestamp.
Answer: C. Only a small fraction (roughly 1/N) of total keys are re-mapped to the new node, minimizing the impact on the hit ratio.
**Consistent Hashing** minimizes reshuffling when the cluster size changes. In a ring topology, adding a node typically only takes ownership of keys from its immediate neighbor on the ring (roughly `1/N` of the total keys). Standard modulo hashing (`key % N`) would re-map nearly `100%` of keys, emptying the cache effectively.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In the Cache-Aside pattern, what happens when the application requests data that is missing from the cache (a 'Cache Miss')?
- Why use a centralized Distributed Cache (like a Redis Cluster) over local in-memory caches on each web server?
- Setting a short TTL (e.g., 60 seconds) on a cached object helps to:
- What is the primary architectural goal of introducing a cache into a system?
- Most caching systems rely on the principle of 'Temporal Locality', which states:
- Your cache uses an LRU (Least Recently Used) eviction policy. When the cache is full, which item is removed?