Question: What is the difference between ElastiCache shards and nodes?


In the context of Amazon ElastiCache, both "shards" and "nodes" are integral components of the service but have different roles.


A node is the smallest building block of an ElastiCache deployment. Each node runs an instance of the cache engine (either Memcached or Redis) and has its own DNS name and port. Nodes are grouped into clusters for management and operational purposes.

Here's how you can create a Redis node using AWS CLI:

aws elasticache create-cache-cluster \ --cache-cluster-id my-cluster \ --cache-node-type cache.r5.large \ --engine redis \ --num-cache-nodes 1 \ --region us-west-2


Sharding, on the other hand, relates to partitioning your data across multiple nodes to improve scalability. In Redis (ElastiCache), a shard is a collection of one to six related nodes. A single shard contains a primary node and up to five read replicas.

When using sharding in ElastiCache with Redis, you deal with "Replication Groups". A replication group is a collection of one or more shards. Here's an example of creating a replication group using AWS CLI:

aws elasticache create-replication-group \ --replication-group-id my-replication-group \ --replication-group-description my-description \ --automatic-failover-enabled \ --num-node-groups 3 \ --replicas-per-node-group 2 \ --cache-node-type cache.r5.large \ --engine redis \ --region us-west-2

In this command, --num-node-groups specifies the number of shards, and --replicas-per-node-group specifies the number of read replicas in each shard.

In conclusion, while nodes represent individual units running the cache engine, shards are logical groupings of nodes that help in distributing your data to improve performance and availability.

Was this content helpful?

Start building today

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