E-R Model of Redis Cluster
The Redis module organizes production Redis into clusters. A cluster is a logical entity with Redis instances on one or more nodes.
Each cluster is an autonomous, high-performance cache or storage unit with at least one Redis instance. It exposes services through ports.
There are three core entities in Pigsty’s Redis module:
- Cluster: An autonomous Redis service unit and the top-level namespace for other entities.
- Instance: One Redis server process using a specific port on a node.
- Node: An implicitly declared hardware resource that runs Linux and Systemd. It can host multiple Redis instances.
Redis usually runs multiple instances per node, unlike PostgreSQL. This uses multiple CPU cores on a physical server or VM. Nodes and instances therefore have a 1:N relationship. For production, Redis instances with more than 12 GB of memory are generally discouraged.
Operating Modes
redis_mode selects one of three Redis modes:
| Mode | Code | Description | HA Mechanism |
|---|---|---|---|
| Standalone | standalone | Classic master-replica, default mode | Requires Sentinel |
| Sentinel | sentinel | HA monitoring and auto-failover for standalone | Multi-node quorum |
| Native Cluster | cluster | Redis native distributed cluster, no sentinel needed | Built-in auto-failover |
- Standalone: The default mode. Set replication with
replica_of. HA requires a separate Sentinel cluster. - Sentinel: Monitor standalone clusters and provide automatic failover. Sentinel stores no business data. Multiple nodes provide HA for Sentinel itself.
- Native Cluster: Automatically shard data across multiple primaries. Each primary can have multiple replicas. Built-in HA removes the need for Sentinel.
Examples
The following examples show each mode.
Standalone Cluster
Classic master-replica on a single node:
| Cluster | Description |
|---|---|
redis-ms | Redis standalone cluster |
| Node | Description |
redis-ms-1 | 10.10.10.10 Node #1, hosts 2 instances |
| Instance | Description |
redis-ms-1-6379 | Primary instance, listening on port 6379 |
redis-ms-1-6380 | Replica instance, port 6380, replicates from 6379 |
Sentinel Cluster
This example puts three Sentinel instances on one node. redis_sentinel_monitor specifies the standalone clusters they monitor:
Native Cluster
This native distributed cluster has two nodes and six instances: the minimum specification of three primaries and three replicas.
This creates a 3 primary 3 replica native Redis cluster.
| Cluster | Description |
|---|---|
redis-test | Redis native cluster (3P3R) |
| Instance | Description |
redis-test-1-6379 | Instance on node 1, port 6379 |
redis-test-1-6380 | Instance on node 1, port 6380 |
redis-test-1-6381 | Instance on node 1, port 6381 |
redis-test-2-6379 | Instance on node 2, port 6379 |
redis-test-2-6380 | Instance on node 2, port 6380 |
redis-test-2-6381 | Instance on node 2, port 6381 |
| Node | Description |
redis-test-1 | 10.10.10.12 Node #1, hosts 3 instances |
redis-test-2 | 10.10.10.13 Node #2, hosts 3 instances |
Identity Parameters
The REDIS parameter group assigns deterministic identities to Redis entities. Three parameters are required:
| Parameter | Type | Level | Description | Format |
|---|---|---|---|---|
redis_cluster | string | Cluster | Redis cluster name, required | Valid DNS name, regex [a-z][a-z0-9-]* |
redis_node | int | Node | Redis node number, required | Natural number, starting from 1, unique within cluster |
redis_instances | dict | Node | Redis instance definition, required | JSON object, key is port, value is instance config |
Set the cluster name at cluster level. Set the node number and instance definitions at node level. Pigsty generates these unique identifiers:
| Entity | Generation Rule | Example |
|---|---|---|
| Instance | {{ redis_cluster }}-{{ redis_node }}-{{ port }} | redis-ms-1-6379, redis-ms-1-6380 |
Redis uses the existing hostname or IP address as the host node identity. It does not assign another identity. redis_node names instances, not host nodes.
Instance Definition
redis_instances is a JSON object. Each key is a port number; its value is the instance configuration:
Each Redis instance must use a unique port on its node. Avoid reserved ports below 1024 and conflicts with Pigsty ports. In standalone mode, replica_of defines replication. Use format '<ip> <port>' to specify the upstream primary address and port.
Each Redis node also runs Redis Exporter to collect metrics from all local instances:
| Port | Parameter | Purpose |
|---|---|---|
| 9121 | redis_exporter_port | Redis Exporter port |
The Redis deployment model has these limits:
- Node Exclusive: A node can belong to only one Redis cluster at a time.
- Port Unique: Instances on the same node must use different ports.
- Password Shared: Instances on the same node must share a password because of a redis_exporter limitation.
- Manual HA: Standalone clusters require additional Sentinel configuration for automatic failover.
Monitoring Label System
The built-in monitoring system uses these identity parameters to identify Redis entities.
The labels cls, ins, and ip identify the cluster name, instance name, and node IP. They accompany job in all Redis metrics collected by VictoriaMetrics. The Redis metrics job is always redis.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)