0
0
AWScloud~5 mins

Why auto scaling matters in AWS - Performance Analysis

Choose your learning style9 modes available
Time Complexity: Why auto scaling matters
O(n)
Understanding Time Complexity

We want to understand how the work needed to handle growing traffic changes when using auto scaling.

How does the number of servers and their management grow as demand increases?

Scenario Under Consideration

Analyze the time complexity of the following operation sequence.

# AWS Auto Scaling example
aws autoscaling create-auto-scaling-group --auto-scaling-group-name my-asg \
  --launch-configuration-name my-launch-config --min-size 1 --max-size 10 \
  --desired-capacity 1 --vpc-zone-identifier subnet-12345

aws autoscaling put-scaling-policy --auto-scaling-group-name my-asg \
  --policy-name scale-out --scaling-adjustment 1 --adjustment-type ChangeInCapacity

# When CPU > 70%, scale out by 1 instance
# When CPU < 30%, scale in by 1 instance

This sequence sets up an auto scaling group that adds or removes servers based on CPU load.

Identify Repeating Operations
  • Primary operation: Launching or terminating EC2 instances as load changes.
  • How many times: Depends on how often load crosses thresholds, up to max-size times.
How Execution Grows With Input

As demand (load) grows, the number of instances increases one by one until the max limit.

Input Size (Load Level)Approx. Instances Running
Low (10%)1 (minimum)
Medium (50%)5 (half max)
High (90%)10 (max)

Pattern observation: The number of instances grows roughly linearly with demand until the max limit.

Final Time Complexity

Time Complexity: O(n)

This means the number of servers and scaling actions grows linearly as demand increases.

Common Mistake

[X] Wrong: "Auto scaling instantly adds all needed servers at once regardless of demand."

[OK] Correct: Auto scaling adds or removes servers step-by-step based on policies and thresholds, not all at once.

Interview Connect

Understanding how auto scaling grows with demand shows you can design systems that handle traffic smoothly and efficiently.

Self-Check

"What if the auto scaling group had no max size limit? How would the time complexity change?"