Skip to content
Log In Sign Up info@muvcloud.com

How Data Is Spread

A cluster divides the key space into 16384 hash slots. Redis computes a CRC16 checksum of each key name and takes it modulo 16384 to find the slot, and every primary owns a range of slots. A client that sends a command to the wrong node gets a MOVED reply naming the node that owns the slot.

Primaries, Replicas, and Failover

Each primary can have one or more replicas. The nodes check each other over a separate cluster bus. When a majority of primaries agree that a primary has been unreachable for longer than cluster-node-timeout, one of its replicas is promoted. That vote needs at least three primaries, so the usual minimum is six nodes: three primaries and three replicas, on separate servers.

Replication is asynchronous, so a failover can lose the last writes a primary accepted before it failed.

Ports and Configuration

Every node uses two ports: the client port, 6379 by default, and the cluster bus port, which by default is the client port plus 10000 (16379) and can be changed with cluster-port. Open both between the nodes only, never to the internet. In each node's configuration file:

port 6379
bind 10.0.0.11
cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 5000
appendonly yes
requirepass STRONG_PASSWORD
masterauth STRONG_PASSWORD

Redis writes and maintains the nodes-6379.conf file itself; do not edit it. The base install and hardening are in how to install and secure Redis.

Create the Cluster

With all six nodes running, run this once from any of them:

export REDISCLI_AUTH=STRONG_PASSWORD
redis-cli --cluster create \
  10.0.0.11:6379 10.0.0.12:6379 10.0.0.13:6379 \
  10.0.0.14:6379 10.0.0.15:6379 10.0.0.16:6379 \
  --cluster-replicas 1

--cluster-replicas 1 gives each primary one replica. redis-cli shows the planned slot layout and waits until you type yes. The environment variable keeps the password out of the process list.

Check Its State

redis-cli -c -h 10.0.0.11 CLUSTER INFO
redis-cli -c -h 10.0.0.11 CLUSTER NODES
redis-cli --cluster check 10.0.0.11:6379

A healthy cluster reports cluster_state:ok with all 16384 slots assigned. CLUSTER NODES lists each node, its role, and its slot range. Everyday commands are in redis-cli commands.

Clients Must Speak Cluster

In redis-cli, -c makes it follow MOVED redirects. Application libraries need their cluster mode switched on, so they learn the slot map and send each command to the right node. A Redis cluster has only database 0; SELECT with another number is not allowed.

Multi-Key Commands and Hash Tags

Commands that touch several keys, such as MGET, transactions, and Lua scripts, work only when all keys sit in the same slot; otherwise Redis returns a CROSSSLOT error. Hash tags solve this: when a key contains braces, only the part inside them is hashed.

SET {user:1000}:profile "..."
SET {user:1000}:cart "..."

Both keys land in one slot. Use tags sparingly: too many keys behind one tag create a hot slot on one node.

Cluster, Sentinel, or One Node with a Replica

SetupShards dataAutomatic failover
Node plus replicaNoNo
SentinelNoYes
ClusterYesYes

When You Do Not Need It

If the data fits in the memory of one server and one primary handles the writes, a cluster adds work without benefit: more servers, client settings, and the multi-key limits above. For a cache or a session store, one node with a replica is often enough, and Sentinel adds failover. The general trade-offs are in high availability.

Valkey, an open-source fork of Redis backed by the Linux Foundation, uses the same cluster model and commands; from version 9.0 it can also allow numbered databases in cluster mode.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations