Each test is 5 questions with varying difficulty.
AI Prep covers AI Agents, Generative AI, ML Fundamentals, NLP & LLMs and a lot more, with adaptive tests and daily challenges. Fully offline on Android. Free to try, one-time unlock for lifetime access.
Redis Cluster and Sharding are critical architectural components for scaling high-performance data stores in 2026. As modern applications demand sub-millisecond latency at massive scale, understanding how Redis distributes data across nodes is essential for Senior Software Engineers, Data Engineers, and Site Reliability Engineers. Interviewers focus on this topic to assess a candidate's ability to design systems that handle horizontal scaling, fault tolerance, and data consistency without sacrificing performance. Junior-level candidates are expected to understand the basic concept of partitioning and the role of hash slots, while senior candidates must demonstrate deep knowledge of cluster topology, the mechanics of resharding without downtime, and how to handle failover events in a production environment. Mastery of these concepts is a high-signal indicator of an engineer's capability to manage distributed state and ensure high availability in complex cloud-native architectures.
Redis Cluster and Sharding are the primary mechanisms for overcoming the memory and CPU limitations of a single Redis instance. In 2026, as AI-driven applications and real-time analytics platforms generate massive volumes of transient state, the ability to scale Redis horizontally is a business-critical requirement. A strong understanding of these topics allows engineers to build systems that maintain performance under heavy load while ensuring that the failure of a single node does not bring down the entire cache layer. This topic is a high-signal interview area because it forces candidates to move beyond simple CRUD operations and reason about the complexities of network partitions, data migration, and cluster membership protocols. A weak answer often ignores the nuances of slot migration or the impact of cluster topology on client-side routing, whereas a strong answer addresses the trade-offs between availability and consistency during cluster reconfigurations. With the rise of disaggregated storage and compute, understanding how to manage distributed state effectively is more relevant than ever for building resilient, scalable infrastructure.
Redis Cluster utilizes a decentralized architecture where nodes communicate via a binary protocol over a dedicated cluster bus. The keyspace is partitioned into 16,384 hash slots, each assigned to a primary node. Clients interact with the cluster by maintaining a local map of slot-to-node assignments, enabling direct routing to the appropriate shard.
Client requests are routed to the node owning the hash slot. If a node does not own the slot, it returns a MOVED error containing the correct node address, prompting the client to update its local map and retry.
[Client Application]
↓
[Cluster Slot Map]
↓ ↓
[Node A] ↔ [Node B]
↓ ↓
[Replica] [Replica]
↓ ↓
[Cluster Bus]
↓ ↓
[Heartbeat / Gossip]
Clients maintain a local cache of the cluster topology and proactively update it upon receiving MOVED or ASK errors.
Trade-offs: Reduces network hops but requires client-side state management.
Using MIGRATE command in a loop to move keys between nodes during resharding to minimize blocking.
Trade-offs: Ensures data integrity but increases latency during the migration window.
Directing read-heavy traffic to replica nodes using the READONLY command.
Trade-offs: Increases read capacity but introduces potential stale data reads.
| Reliability | Achieved through master-replica replication and automated failover. Use at least 3 master nodes for quorum. |
| Scalability | Horizontal scaling by adding nodes and migrating hash slots. Limited by the 16,384 slot count. |
| Performance | Direct client routing minimizes latency. Bottlenecks occur at high-traffic hot keys. |
| Cost | Driven by memory usage and node count. Use smaller instances for better granularity. |
| Security | Requires TLS for inter-node communication and ACLs for client access control. |
| Monitoring | Track cluster_state, cluster_slots_fail, and replication lag metrics. |
Redis Sentinel is a monitoring and failover solution for standalone or master-replica setups, providing high availability but not horizontal scaling. Redis Cluster provides both high availability and horizontal sharding by distributing data across multiple master nodes.
Yes, but only if all keys involved in the operation map to the same hash slot. You can force this behavior using hash tags, where keys like {user:1}:profile and {user:1}:settings are guaranteed to be in the same slot.
If a master node fails, the cluster promotes one of its replicas to master. If the failed master has no replicas, the cluster will stop accepting writes for the slots owned by that master unless 'cluster-require-full-coverage' is disabled.
This number was chosen as a balance between the cluster bus bandwidth requirements and the ability to rebalance data. 16,384 slots allow for a cluster size of up to 1,000 nodes while keeping the heartbeat packet size manageable.
Redis Cluster provides eventual consistency. Writes are acknowledged once the master processes them, and replication to slaves happens asynchronously. For stronger consistency, you can use the WAIT command to ensure a write is replicated to a specific number of replicas.
You add the node using 'redis-cli --cluster add-node', then use 'redis-cli --cluster reshard' to migrate hash slots from existing master nodes to the new node to balance the data load.
A MOVED error indicates that a slot is permanently assigned to another node, and the client should update its slot map. An ASK error indicates that a slot is currently being migrated, and the client should query the target node only for that specific request without updating its map.
While possible, it is generally redundant. Redis Cluster handles its own routing and sharding, whereas Twemproxy is typically used to shard data across multiple standalone Redis instances that are not cluster-aware.
The cluster bus uses a small amount of bandwidth for periodic heartbeats and state updates. In very large clusters, this can become significant, so it is important to monitor network traffic and ensure sufficient bandwidth is allocated.
The theoretical maximum is 16,384 nodes (one per slot), but in practice, clusters are typically limited to 1,000 nodes to keep the gossip protocol overhead and configuration propagation time within acceptable limits.
AI Prep covers AI Agents, Generative AI, ML Fundamentals, NLP & LLMs and a lot more, with adaptive tests and daily challenges. Fully offline on Android. Free to try, one-time unlock for lifetime access.