Introducing Dragonfly Cloud! Learn More

Question: How do you perform vertical scaling in ElastiCache?

Answer

Vertical scaling, also known as scaling up, in Amazon ElastiCache refers to the process of increasing the capacity of your cache cluster by changing the node type. This involves modifying the instance type to a larger one for more compute power, memory, and network bandwidth.

Here are the steps to vertically scale an ElastiCache for Redis or Memcached cluster:

  1. Create a snapshot: Before starting the scaling process, it's important to create a snapshot if you're using Redis. The snapshot serves as a backup that can help restore your database in case there are any issues during scaling. Snapshots are not needed for Memcached as it doesn't support data persistence.
import boto3 client = boto3.client('elasticache') response = client.create_snapshot( SnapshotName='mysnapshot', ReplicationGroupId='myreplicationgroup', # Use CacheClusterId for non-replicated Redis or Memcached )
  1. Modify the node type: You can modify the node type via AWS Management Console, AWS CLI, or SDKs. Please note there will be a few minutes of downtime because AWS will replace the existing node with a new one during this process.
response = client.modify_replication_group( ReplicationGroupId='myreplicationgroup', # Use CacheClusterId for non-replicated Redis or Memcached CacheNodeType='cache.m5.large', # New node type ApplyImmediately=True, )

Replace 'cache.m5.large' with the desired node type.

  1. Monitor the scaling process: Monitor the modified cluster to ensure its status transitions from modifying to available.
response = client.describe_replication_groups( ReplicationGroupId='myreplicationgroup', # Use CacheClusterId for non-replicated Redis or Memcached ) print(response['ReplicationGroups'][0]['Status'])
  1. Test the scaled cluster: After the status changes to available, test the modified cache cluster to ensure it's behaving as expected.

It's important to note that vertical scaling should be carefully planned and executed during off-peak hours, as it can cause service interruption. Finally, verify that the scaled-up node type can accommodate your workload demands in terms of CPU, memory, and network performance.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today 

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