Amazon EC2 Auto Scaling
Cloud service · AWS · Updated

Amazon EC2 Auto Scaling

In short

Amazon EC2 Auto Scaling is a service that automatically adjusts the number of Amazon EC2 instances in your deployment to maintain performance and minimize costs based on defined conditions such as traffic or resource utilization.

Cloud Services Hub →

10 key features of Amazon EC2 Auto Scaling

Amazon EC2 Auto Scaling dynamically adjusts the number of Amazon EC2 instances in your application to maintain performance and efficiently manage costs by automatically launching or terminating instances based on predefined policies, health status checks, and schedules.

01
Dynamic Scaling

Automatically adjusts the number of instances in your application to match demand, maintaining performance and minimizing cost.

02
Scheduled Scaling

Allows you to scale your application ahead of known usage patterns by scheduling exactly when and how to scale your application.

03
Health Checks

Uses EC2 health checks to monitor instance health and availability and replace terminated or impaired instances to maintain desired capacity. You can also define application-specific custom health checks; instances that fail them are automatically replaced.

04
Integration with AWS Services

Seamlessly integrates with other AWS services like Amazon EC2, Amazon CloudWatch, and Elastic Load Balancing for comprehensive cloud resource management.

05
Predictive Scaling

Uses machine learning algorithms to automatically predict future traffic patterns and schedule the right number of EC2 instances in advance.

06
Cost Management

Optimizes costs through instance rebalancing and offers the possibility to use Spot Instances and Reserved Instances within the auto-scaling groups.

07
Lifecycle Hooks

Allows you to perform custom actions by pausing instances as an Auto Scaling group launches or terminates them, giving you greater control over your EC2 instances.

08
Multiple Scaling Strategies

Supports multiple scaling strategies such as target tracking scaling, step scaling, and simple scaling policies to fit different use cases.

09
Availability Zone Balancing

When you specify multiple Availability Zones for a group, Amazon EC2 Auto Scaling balances instances evenly across those zones as the group scales, improving resilience to failures in a single location.

10
Spot Capacity Rebalancing

Capacity Rebalancing monitors Spot Instances for elevated interruption risk and can proactively replace them before interruption.

Where Amazon EC2 Auto Scaling is used

Amazon EC2 Auto Scaling is used to ensure application availability and optimize resource utilization by automatically adjusting the number of EC2 instances in response to demand, for workloads ranging from dynamic web applications to batch processing and container management.

  1. 01
    High Availability and Fault Tolerance

    Amazon EC2 Auto Scaling uses EC2 health checks to monitor instance health and availability and replaces terminated or impaired instances to maintain desired capacity. Application-specific health checks can also be defined to verify that the application responds as expected; instances that fail these custom checks are automatically replaced.

  2. 02
    Cost Optimization

    By automatically adjusting the number of Amazon EC2 instances in response to the demand, EC2 Auto Scaling can help reduce costs during off-peak times by terminating instances that are not needed and launching instances during peak times to handle the load. This ensures that you're only paying for the resources you actually need.

  3. 03
    Dynamic Scaling for Microservices

    EC2 Auto Scaling can be configured to dynamically scale the resources for microservices architecture based applications. As microservices have varying load patterns and require different resources, EC2 Auto Scaling can adjust the capacity of each service independently, ensuring optimal performance and resource utilization.

  4. 04
    Batch Processing Workloads

    For batch processing jobs that require significant computational power for short durations, EC2 Auto Scaling can rapidly provision the necessary resources to complete the job efficiently and terminate them once the job is done. This use case is ideal for data processing, rendering, or any task that requires heavy computational resources intermittently.

  5. 05
    Scheduled Scaling for Predictable Workloads

    For workloads with predictable patterns, such as higher usage during business hours and lower usage at night, EC2 Auto Scaling can schedule scaling actions to automatically adjust capacity in anticipation of the changes in demand. This ensures that the application can handle the user load without manual intervention.

How Amazon EC2 Auto Scaling is priced

Amazon EC2 Auto Scaling is priced based on the underlying EC2 instances or other resources used, without additional charges specifically for the Auto Scaling service itself.

On-Demand Instances

Pay for the compute capacity by the hour or by the second depending on the instances you run with no long-term commitments or upfront payments. This model gives you flexibility to increase or reduce compute capacity on demand and only pay for what you use.

Reserved Instances

Purchase EC2 instances for a one-year or three-year term, and receive a significant discount compared to On-Demand instance pricing. This option is ideal for applications with steady state or predictable usage, offering budget predictability and lower costs in exchange for committing to use EC2 over a longer period.

Spot Instances

Use unused EC2 capacity at a potentially lower price than On-Demand rates. Spot Instances can significantly lower your computing costs for time-flexible and interruption-tolerant applications but can be stopped by EC2 with little notice if the Spot price exceeds an optional maximum price you specify or if capacity is unavailable.

Savings Plans

Commit to a consistent amount of usage (e.g., $10/hour) for a 1-year or 3-year term and receive a lower price compared to On-Demand pricing. Savings Plans offer the flexibility to use the compute option that best suits your needs and still benefit from savings.

Dedicated Hosts

Pay for a physical EC2 server dedicated for your use, which can help you reduce costs by allowing you to use your existing server-bound software licenses. This model offers visibility and control over where your instances run and is useful for regulatory requirements that require physical isolation.

No Additional Auto Scaling Fees

Amazon EC2 Auto Scaling has no additional fees beyond the charges for Amazon EC2, CloudWatch used for scaling policies, and other AWS resources you use.

Services Amazon EC2 Auto Scaling works with

Amazon CloudWatchAmazon CloudWatch

Provides monitoring for AWS cloud resources and applications, enabling Auto Scaling to dynamically adjust capacity based on predefined thresholds or alarms.

Amazon DevOps GuruAmazon DevOps Guru

Amazon EC2 Auto Scaling groups are supported resources for DevOps Guru analysis. DevOps Guru analyzes their operational metrics and related events to identify anomalous behavior and provide recommendations.

Amazon EC2Amazon EC2

Amazon EC2 Auto Scaling launches and terminates EC2 instances using launch templates, scaling policies, scheduled actions, and health checks. Groups can combine instance types and purchase options, use Capacity Reservations, and proactively replace at-risk Spot Instances.

Amazon Elastic Block Store (Amazon EBS)Amazon Elastic Block Store (Amazon EBS)

Amazon EC2 Auto Scaling uses the block device mappings in its launch template to create and attach EBS volumes when instances launch. Those mappings also control whether volumes are deleted when Auto Scaling terminates an instance.

Amazon Elastic Container Service (Amazon ECS)Amazon Elastic Container Service (Amazon ECS)

Amazon EC2 Auto Scaling groups provide EC2 capacity for ECS clusters through Auto Scaling group capacity providers. ECS managed scaling adjusts group capacity to accommodate tasks, while managed termination protection helps prevent instances with running tasks from being terminated prematurely.

Amazon Elastic Kubernetes Service (Amazon EKS)Amazon Elastic Kubernetes Service (Amazon EKS)

Amazon EC2 Auto Scaling groups supply worker nodes for EKS managed node groups and can also support self-managed nodes. EKS manages the underlying groups for managed node groups, and Kubernetes Cluster Autoscaler can adjust group capacity when pods need more or fewer nodes.

Amazon EventBridgeAmazon EventBridge

Amazon EC2 Auto Scaling sends instance lifecycle, scaling activity, instance refresh, and other events to EventBridge. Rules can route these events to automation or notification targets, such as invoking a function when an instance enters a lifecycle-hook wait state.

Amazon GameLiftAmazon GameLift

Amazon EC2 Auto Scaling groups provide the instances behind GameLift FleetIQ game server groups. FleetIQ manages the underlying group to balance game-server availability and cost, including replacing Spot capacity that becomes unsuitable for game hosting.

Amazon Simple Notification Service (Amazon SNS)Amazon Simple Notification Service (Amazon SNS)

Amazon EC2 Auto Scaling can publish notifications about instance launches, terminations, and related failures to SNS topics. Lifecycle hooks can also send notifications to SNS so subscribers can perform initialization or cleanup before the lifecycle action completes.

Amazon Simple Queue Service (Amazon SQS)Amazon Simple Queue Service (Amazon SQS)

Amazon EC2 Auto Scaling lifecycle hooks can send messages to SQS queues for workers to process before an instance finishes launching or terminating. Worker groups can also scale using a CloudWatch metric that expresses SQS backlog per instance.

What is Amazon EC2 Auto Scaling

3 min read

Amazon EC2 Auto Scaling is a cloud computing service that automatically adjusts the number of Amazon Elastic Compute Cloud (EC2) instances in your cloud environment. This service is designed to ensure that your application has the right amount of compute capacity to handle the demand at any given time. Its primary goal is to maintain application availability and allow users to scale their Amazon EC2 capacity up or down automatically according to conditions defined by the user. 

At its core, Amazon EC2 Auto Scaling helps in enhancing the reliability, availability, and cost-efficiency of applications running on the Amazon Web Services (AWS) infrastructure. It does this by dynamically adjusting the number of EC2 instances in response to real-time demand, mitigating the need for manual intervention. This means that it can automatically launch additional instances when demand spikes to maintain performance and shut down instances during demand dips to reduce costs. The process begins by setting up Auto Scaling groups, which are collections of EC2 instances treated as a logical unit for the purposes of scaling and management. When creating an Auto Scaling group, you specify the minimum and maximum number of instances, desired capacity, and other parameters related to how the group should scale. Within these parameters, you can define scaling policies based on a variety of metrics such as average CPU utilization, network traffic, or even based on custom metrics specific to your application. 

A single Auto Scaling group can combine multiple instance types and both Spot and On-Demand Instances. Reserved Instance and Savings Plans discounts can apply to On-Demand Instances in the group.

One of the critical advantages of using Amazon EC2 Auto Scaling is its tight integration with other AWS services such as Amazon CloudWatch for monitoring, AWS Lambda for serverless computing, and Elastic Load Balancing (ELB) for distributing incoming traffic across the instances. This integration allows for a more robust and flexible management system that can automatically respond to changes in traffic by adjusting the capacity, thereby ensuring that your application remains responsive at all times. 

Additionally, Amazon EC2 Auto Scaling supports launch configurations and launch templates that define the instance type, AMI (Amazon Machine Image), and other configurations. This means you can automatically start new instances with the desired setup without manual intervention, ensuring that new instances are configured identically to existing ones. It plays a crucial role in disaster recovery by maintaining application availability through the automatic replacement of instances that may fail, become unhealthy, or otherwise become unavailable. 

AWS recommends using EC2 launch templates rather than launch configurations because launch templates offer more features.

In summary, Amazon EC2 Auto Scaling is a critical service for businesses and developers that require their applications to be highly available and performant without the overhead of managing and adjusting compute capacity manually. By automating the scaling process based on real-time metrics, it not only optimizes costs but also ensures that applications can handle varying load conditions without human intervention, contributing to smoother operations and a better end-user experience.

Amazon EC2 Auto Scaling uses token-bucket API throttling with a shared API bucket, so calls to operations such as DescribeAutoScalingGroups and DescribeScheduledActions consume the same pool of tokens. Requests that exceed the service's requests-per-second limit are rejected with a RateExceeded error.

Concepts related to Amazon EC2 Auto Scaling

Amazon EC2 Auto Scaling exam questions

Real practice exam questions on Amazon EC2 Auto Scaling, with the correct answer and its explanation. Answer them with every option in the exam simulator.

CLF-C02

A retailer has configured automatic scaling for an Amazon EC2 Auto Scaling group. After a promotional event, a manager wants evidence that compute capacity increased as demand rose and decreased after demand fell. The group's instance-count metrics are enabled. Which approach best demonstrates this behavior without changing the scaling configuration?

Show answerCORRECT ANSWER

Use an Amazon CloudWatch dashboard to compare application request volume with the group's in-service instance count throughout the promotion and afterward.

CloudWatch can display demand metrics alongside Auto Scaling group instance-count metrics over time. This comparison provides evidence that capacity increased during high demand and was released when demand fell, demonstrating elasticity.

MLA-C02

A company runs a custom ML inference service on an Amazon EC2 Auto Scaling group. Target tracking adjusts the number of serving instances as traffic changes. Preparing a newly launched instance takes 12 minutes because it must download and validate model artifacts on its encrypted Amazon EBS root volume. Once the artifacts are on disk, starting the instance and loading the model into memory takes 45 seconds.

Unpredictable traffic increases require up to four additional serving instances within 90 seconds. These increases are sufficiently far apart to replenish a reserve of four prepared instances. The company must retain target tracking and minimize EC2 compute charges for reserve capacity while it is idle. The application does not need to preserve in-memory state.

Which solution best meets these requirements?

Show answerCORRECT ANSWER

Configure a warm pool that maintains four prepared instances in the Stopped state. Use lifecycle hooks to complete artifact download and validation before instances enter the pool, and verify model readiness before they begin serving traffic.

A stopped warm pool preserves the prepared EBS volumes without incurring EC2 instance compute charges while the instances are stopped. Instances can start and load the cached model in 45 seconds, meeting the 90-second requirement. Lifecycle hooks coordinate preparation and readiness with the Auto Scaling lifecycle. EBS storage charges still apply.

SAP-C03

A company runs a latency-sensitive application in an Amazon EC2 Auto Scaling group. The group has two step scaling policies invoked by Amazon CloudWatch alarms. One policy uses average CPU utilization. The other uses a custom ActiveRequestsPerInstance metric. Both metrics are valid indicators of application load.

Before deploying the configuration, a solutions architect reviews two independent test cases:

• Scale-out test: The desired capacity is 20 instances. Both policies act simultaneously. The CPU policy requests an increase of 6 instances, and the custom-metric policy requests an increase of 10 instances.
• Scale-in test: The desired capacity is reset to 20 instances. Both policies act simultaneously. The CPU policy requests a decrease of 6 instances, and the custom-metric policy requests a decrease of 2 instances.

All instances have equal capacity. Both policies are eligible to act, no instances are warming up, and group capacity limits do not constrain either test. No other scaling actions occur.

The company wants to retain both metric-based responses with the least custom operational logic. Which implementation and expected desired capacities are correct?

Show answerCORRECT ANSWER

Keep both policies attached to the group and let EC2 Auto Scaling resolve simultaneous actions. Expect 30 instances after the scale-out decision and 18 instances after the scale-in decision.

EC2 Auto Scaling supports multiple dynamic scaling policies and chooses the policy that provides the largest resulting capacity when policies act simultaneously. The scale-out candidates are 26 and 30, so it chooses 30. The scale-in candidates are 14 and 18, so it chooses 18. Native arbitration requires no custom coordination.

Practice Amazon EC2 Auto Scaling in a full exam

Questions on Amazon EC2 Auto Scaling in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

Learn Amazon EC2 Auto Scaling in lessons

16 short lessons on Amazon EC2 Auto Scaling in 6 certification courses.

and 10 more lessons

Open the lessons

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.