Question: What is the minimum number of nodes required in a Redis cluster?


A Redis Cluster requires a minimum of six nodes for it to operate correctly. This configuration includes three master nodes and three corresponding slave nodes, one for each master.

The reason for this setup is due to how Redis Cluster handles its failover mechanism. When a master node fails, an automatic failover process begins in which the slaves vote whether to promote one of themselves as the new master. To prevent "split-brain" scenarios where two parts of the network think they are authoritative, a majority of master nodes (at least 2 out of 3 in the case of the minimal configuration) must be able to communicate with each other and agree on the state of the network.

Here's an example of how you might start up a minimal Redis cluster:

# Start the master nodes redis-server --port 7000 --cluster-enabled yes --cluster-config-file nodes-7000.conf redis-server --port 7001 --cluster-enabled yes --cluster-config-file nodes-7001.conf redis-server --port 7002 --cluster-enabled yes --cluster-config-file nodes-7002.conf # Start the slave nodes redis-server --port 7003 --cluster-enabled yes --cluster-config-file nodes-7003.conf --cluster-slave --cluster-master-id <ID_OF_7000_NODE> redis-server --port 7004 --cluster-enabled yes --cluster-config-file nodes-7004.conf --cluster-slave --cluster-master-id <ID_OF_7001_NODE> redis-server --port 7005 --cluster-enabled yes --cluster-config-file nodes-7005.conf --cluster-slave --cluster-master-id <ID_OF_7002_NODE>

In these commands, --cluster-enabled yes enables cluster mode, --cluster-config-file nodes-xxxx.conf specifies a config file for each node, and --cluster-slave --cluster-master-id <ID_OF_XXXX_NODE> sets the node as a slave of a specified master node.

Was this content helpful?

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.