Question: What is the difference between ElastiCache shards and nodes?
Answer
In the context of Amazon ElastiCache, both "shards" and "nodes" are integral components of the service but have different roles.
Nodes
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
Shards
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?
Other Common ElastiCache Questions (and Answers)
- How to configure ElastiCache in AWS?
- How to view ElastiCache data?
- Is ElastiCache stateless?
- What is ElastiCache Replication Group?
- When to use ElastiCache vs DynamoDB?
- When to use ElastiCache?
- Can ElastiCache store session data?
- How to improve ElastiCache performance?
- How does AWS ElastiCache work?
- Can't connect to ElastiCache Redis
- Is ElastiCache a database?
- How to clear Elasticache?
Free System Design on AWS E-Book
Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.
Switch & save up to 80%
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost