AWS free tier overview - Time & Space Complexity
We want to understand how the number of AWS operations grows when using the free tier services.
Specifically, how does usage scale as you add more resources or requests?
Analyze the time complexity of launching multiple EC2 instances under the free tier limits.
// Launch multiple EC2 instances
for (let i = 0; i < n; i++) {
aws.ec2.runInstances({
ImageId: 'ami-0abcdef1234567890',
InstanceType: 't2.micro',
MinCount: 1,
MaxCount: 1
});
}
This sequence launches n EC2 instances one by one within free tier limits.
Here are the repeating actions:
- Primary operation: The API call to launch one EC2 instance (runInstances).
- How many times: This call happens once per instance, so n times.
Each new instance requires one API call, so the total calls grow directly with the number of instances.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The number of API calls increases evenly as you add more instances.
Time Complexity: O(n)
This means the time or effort grows directly in proportion to how many instances you launch.
[X] Wrong: "Launching multiple instances is just one API call regardless of number."
[OK] Correct: Each instance requires its own API call, so the total calls add up with more instances.
Understanding how AWS API calls scale helps you design efficient cloud solutions and shows you can think about resource costs clearly.
"What if we launched multiple instances in a single API call using MaxCount > 1? How would the time complexity change?"