Amazon Managed Streaming for Apache Kafka (MSK) and Application Auto Scaling - Application Auto Scaling
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon Managed Streaming for Apache Kafka (MSK) and Application Auto Scaling

You can scale out Amazon MSK cluster storage using target tracking scaling policies. Scale in by the target tracking policy is disabled.

Use the following information to help you integrate Amazon MSK with Application Auto Scaling.

Service-linked role created for Amazon MSK

The following service-linked role is automatically created in your Amazon Web Services account when registering Amazon MSK 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_KafkaCluster

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:

  • kafka.application-autoscaling.amazonaws.com

Registering Amazon MSK cluster storage as scalable targets with Application Auto Scaling

Application Auto Scaling requires a scalable target before you can create a scaling policy for the storage volume size per broker of an Amazon MSK cluster. A scalable target is a resource that Application Auto Scaling can scale. Scalable targets are uniquely identified by the combination of resource ID, scalable dimension, and namespace.

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

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

  • Amazon CLI:

    Call the register-scalable-target command for an Amazon MSK cluster. The following example registers the storage volume size per broker of an Amazon MSK cluster, with a minimum capacity of 100 GiB and a maximum capacity of 800 GiB.

    aws application-autoscaling register-scalable-target \ --service-namespace kafka \ --scalable-dimension kafka:broker-storage:VolumeSize \ --resource-id arn:aws-cn:kafka:us-east-1:123456789012:cluster/demo-cluster-1/6357e0b2-0e6a-4b86-a0b4-70df934c2e31-5 \ --min-capacity 100 \ --max-capacity 800

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

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

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

Note

When an Amazon MSK cluster is the scalable target, scale in is disabled and cannot be enabled.

If you are just getting started with Application Auto Scaling, you can find additional useful information about scaling your Amazon MSK resources in the following documentation:

Automatic scaling in the Amazon Managed Streaming for Apache Kafka Developer Guide