0
0
AWScloud~5 mins

Scaling policies (target tracking, step, simple) in AWS - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Scaling policies (target tracking, step, simple)
O(n)
Understanding Time Complexity

When using scaling policies in AWS, it's important to understand how the number of scaling actions grows as demand changes.

We want to know how the system reacts over time as load increases or decreases.

Scenario Under Consideration

Analyze the time complexity of these scaling policy operations.


aws application-autoscaling put-scaling-policy --policy-name my-step-policy --service-namespace ecs \
  --resource-id service/default/sample-webapp --scalable-dimension ecs:service:DesiredCount \
  --policy-type StepScaling --step-scaling-policy-configuration file://step-config.json

aws application-autoscaling put-scaling-policy --policy-name my-target-tracking-policy --service-namespace ecs \
  --resource-id service/default/sample-webapp --scalable-dimension ecs:service:DesiredCount \
  --policy-type TargetTrackingScaling --target-tracking-scaling-policy-configuration file://target-tracking.json
    

These commands set up step and target tracking scaling policies for an ECS service.

Identify Repeating Operations

Look at what happens repeatedly as load changes:

  • Primary operation: Scaling actions that adjust the number of instances.
  • How many times: Each scaling action happens whenever the metric crosses thresholds or deviates from the target.
How Execution Grows With Input

As load increases, the number of scaling actions grows roughly in proportion to how often the metric crosses thresholds.

Input Size (Load Changes)Approx. Scaling Actions
10About 10 scaling actions
100About 100 scaling actions
1000About 1000 scaling actions

Pattern observation: Scaling actions increase linearly with the number of load changes.

Final Time Complexity

Time Complexity: O(n)

This means the number of scaling actions grows directly with the number of load changes.

Common Mistake

[X] Wrong: "Scaling happens instantly and only once regardless of load changes."

[OK] Correct: Scaling policies react each time the metric crosses thresholds, so multiple scaling actions happen as load fluctuates.

Interview Connect

Understanding how scaling actions grow with load helps you design systems that respond well to demand and avoid surprises in performance.

Self-Check

What if we changed from step scaling to simple scaling? How would the time complexity change?