Skip to main content

What does Redis Cluster consist of?

Redis Cluster consists of several types of nodes and support mechanisms that together provide scaling, fault tolerance, and automatic recovery.

1. Master nodes

  • The main working nodes, which hold the data.
  • Every master is responsible for a specific range of hash slots (out of the 16384 possible).
  • They handle writes and reads.

Example:

javascript
master1 → slots 0-5460 master2 → slots 5461-10922 master3 → slots 10923-16383

If a master fails, one of its replicas automatically becomes the new master.

2. Replica nodes

  • Copy a specific master's data and act as a backup.
  • Normally they only read data, but on their master's failure, they perform automatic failover and become the new master.
  • Replication is asynchronous.

Example:

javascript
master1 → replica1 master2 → replica2 master3 → replica3

3. The data-distribution mechanism, hash slots

  • Every Redis Cluster key is distributed across 16384 hash slots.

  • Every master is responsible for a portion of those slots.

  • The distribution is computed with this formula:

    javascript
    CRC16(key) % 16384
  • That lets the cluster know exactly where every key is stored.

4. The Gossip protocol (how nodes interact)

  • The cluster's nodes exchange state with each other through a built-in Gossip protocol.
  • Every node regularly tells the others:
    • what it is (master/replica),
    • which slots it serves,
    • which nodes are available or unavailable.

That lets Redis Cluster operate with no central managing server, the system self-coordinates.

5. The failover mechanism

  • If a master is unreachable, its replica gets confirmation from a majority of the other masters and becomes the new master.
  • The other nodes learn about it through Gossip and update their metadata.

6. Cluster-aware clients

  • Redis clients (drivers) need to understand MOVED and ASK messages.
  • When a key lives on a different node, the client is automatically redirected to the right master.

Redis Cluster's overall structure

javascript
master1 → replica1 master2 → replica2 master3 → replica3 (every node is connected via Gossip) data is distributed across 16384 slots

Summary: Redis Cluster consists of:

  1. Several master nodes, holding the data.
  2. Their replicas, providing fault tolerance.
  3. The hash-slot mechanism, distributing the keys.
  4. The Gossip protocol, connecting every node.
  5. Failover and client-side routing, keeping the system running continuously and letting it scale.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.