Scheduled scaling in AWS - Time & Space 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?
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 the API calls, resource provisioning, data transfers that repeat.
- Primary operation: The
put-scheduled-update-group-actionAPI call to create a scheduled scaling action. - How many times: This call is made once per schedule, so n times.
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 |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The number of API calls grows linearly as you add more scheduled scaling actions.
Time Complexity: O(n)
This means the time to create scheduled scaling actions grows directly in proportion to how many schedules you add.
[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.
Understanding how scheduled scaling scales helps you design systems that grow smoothly and predict how setup time changes as you add more automation.
"What if we batch multiple scheduled scaling actions into a single API call? How would the time complexity change?"