0
0
AWScloud~5 mins

Scheduled scaling in AWS - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Scheduled scaling
O(n)
Understanding Time Complexity

We want to understand how the time to apply scheduled scaling changes as we add more schedules.

How does the number of scheduled scaling actions affect the work done by AWS?

Scenario Under Consideration

Analyze the time complexity of the following operation sequence.


# Create multiple scheduled scaling actions for an Auto Scaling group
for ((i = 0; i < n; i++)); do
  aws autoscaling put-scheduled-update-group-action \
    --auto-scaling-group-name my-asg \
    --scheduled-action-name "scale-action-$i" \
    --start-time 2024-07-01T00:00:00Z \
    --desired-capacity 5

done
    

This sequence creates n scheduled scaling actions, each setting desired capacity at a specific time.

Identify Repeating Operations

Identify the API calls, resource provisioning, data transfers that repeat.

  • Primary operation: The put-scheduled-update-group-action API call to create a scheduled scaling action.
  • How many times: This call is made once per schedule, so n times.
How Execution Grows With Input

Each new scheduled scaling action requires one API call, so the total calls grow directly with the number of schedules.

Input Size (n)Approx. API Calls/Operations
1010
100100
10001000

Pattern observation: The number of API calls grows linearly as you add more scheduled scaling actions.

Final Time Complexity

Time Complexity: O(n)

This means the time to create scheduled scaling actions grows directly in proportion to how many schedules you add.

Common Mistake

[X] Wrong: "Adding more scheduled scaling actions won't affect the time because AWS handles them all at once."

[OK] Correct: Each scheduled action requires a separate API call, so more schedules mean more calls and more time to set up.

Interview Connect

Understanding how scheduled scaling scales helps you design systems that grow smoothly and predict how setup time changes as you add more automation.

Self-Check

"What if we batch multiple scheduled scaling actions into a single API call? How would the time complexity change?"