A shard is a collection of one or more nodes in an ElastiCache cluster. It is created to support replication of data into various nodes in the ElastiCache cluster so that cache remains reachable in case of loss of few nodes. Depending on how the cluster mode is configured, a Redis cluster can have one or more shards. If the cluster mode is disabled, then the Redis cluster will have only one shard.
A shard = Primary Node + Read Replicas
Primary Node
One of the nodes in a shard is designated as a primary node. Applications can write only to the primary node. Data written to the primary are asynchronously propagated to all the read replicas. An existing primary node can exchange its role with one of the read replicas for better performance.
Replicas
Read replica maintains a copy of the data from the cluster’s primary node. Also Read replicas improve read throughput and guard against data loss in cases of a node failure. Applications can read from any node in the cluster whether read replica or primary node.
Disabled Cluster Mode
In this mode we create a Redis cluster in which there is only one shard which contains all the Redis nodes. One of the nodes is designated as primary node and others are called read-only replica nodes.
Following are the features of a Redis cluster in which the cluster mode is disabled.
- All the nodes in a Redis (cluster mode disabled) cluster must reside in the same region. To improve fault tolerance, you can provision read replicas in multiple Availability Zones within that region.
- When you add a read replica to a cluster, all the data from the primary is copied to the new node. From that point on, whenever data is written to the primary, the changes are asynchronously propagated to all the read replicas.
- Use Redis (cluster mode disabled) clusters with replica nodes to scale your Redis solution for ElastiCache to handle applications that are read-intensive.
Cluster Mode Enabled
In this mode we create a Redis cluster in which there are 1 to 90 shards. Each shard has a primary node and up to five read-only replica nodes. Each read replica in a shard maintains a copy of the data from the shard’s primary node.
Following are the features of a Redis cluster in which the cluster mode is disabled.
- Asynchronous replication mechanisms are used to keep the read replicas synchronized with the primary. Applications can read from any node in the cluster. Applications can write only to the primary nodes.
- All of the nodes in this Redis cluster must reside in the same region.
- You cannot manually promote any of the replica nodes to primary.
- You can only change the structure of a cluster, the node type, and the number of nodes by restoring from a backup.