ElastiCache and Application Auto Scaling - Application Auto Scaling

ElastiCache and Application Auto Scaling

You can horizontally scale Amazon ElastiCache replication groups (Redis OSS and Valkey) and Memcached self-designed clusters using target tracking scaling policies and scheduled scaling.

To integrate ElastiCache with Application Auto Scaling, use the following information.

Service-linked role created for ElastiCache

The following service-linked role is automatically created in your AWS account when registering ElastiCache resources as scalable targets with Application Auto Scaling. This role allows Application Auto Scaling to perform supported operations within your account. For more information, see Service-linked roles for Application Auto Scaling.

  • AWSServiceRoleForApplicationAutoScaling_ElastiCacheRG

Service principal used by the service-linked role

The service-linked role in the previous section can be assumed only by the service principal authorized by the trust relationships defined for the role. The service-linked role used by Application Auto Scaling grants access to the following service principal:

  • elasticache.application-autoscaling.amazonaws.com

Registering ElastiCache resources as scalable targets with Application Auto Scaling

Application Auto Scaling requires a scalable target before you can create scaling policies or scheduled actions for an ElastiCache replication group, cluster, or node. A scalable target is a resource that Application Auto Scaling can scale out and scale in. Scalable targets are uniquely identified by the combination of resource ID, scalable dimension, and namespace.

If you configure auto scaling using the ElastiCache console, then ElastiCache automatically registers a scalable target for you.

If you want to configure auto scaling using the AWS CLI or one of the AWS SDKs, you can use the following options:

  • AWS CLI:

    Call the register-scalable-target command for an ElastiCache replication group. The following example registers the desired number of node groups for a replication group called mycluster1, with a minimum capacity of one and a maximum capacity of five.

    aws application-autoscaling register-scalable-target \ --service-namespace elasticache \ --scalable-dimension elasticache:replication-group:NodeGroups \ --resource-id replication-group/mycluster1 \ --min-capacity 1 \ --max-capacity 5

    If successful, this command returns the ARN of the scalable target.

    { "ScalableTargetARN": "arn:aws:application-autoscaling:region:account-id:scalable-target/1234abcd56ab78cd901ef1234567890ab123" }

    The following example registers the desired number of replicas per node group for a replication group called mycluster2, with a minimum capacity of one and a maximum capacity of five.

    aws application-autoscaling register-scalable-target \ --service-namespace elasticache \ --scalable-dimension elasticache:replication-group:Replicas \ --resource-id replication-group/mycluster2 \ --min-capacity 1 \ --max-capacity 5

    If successful, this command returns the ARN of the scalable target.

    { "ScalableTargetARN": "arn:aws:application-autoscaling:region:account-id:scalable-target/234abcd56ab78cd901ef1234567890ab1234" }

    The following example registers the desired number of nodes for a cluster called mynode1, with a minimum capacity of 20 and a maximum capacity of 50.

    aws application-autoscaling register-scalable-target \ --service-namespace elasticache \ --scalable-dimension elasticache:cache-cluster:Nodes \ --resource-id cache-cluster/mynode1 \ --min-capacity 20 \ --max-capacity 50

    If successful, this command returns the ARN of the scalable target.

    { "ScalableTargetARN": "arn:aws:application-autoscaling:region:account-id:scalable-target/01234abcd56ab78cd901ef1234567890ab12" }
  • AWS SDK:

    Call the RegisterScalableTarget operation and provide ResourceId, ScalableDimension, ServiceNamespace, MinCapacity, and MaxCapacity as parameters.

For more information, see Auto Scaling Valkey and Redis OSS clusters and Scaling clusters for Memcached in the Amazon ElastiCache User Guide.