Static website hosting on S3 in AWS - Time & Space Complexity
When hosting a static website on S3, we want to know how the time to upload the website changes as the website grows.
We ask: How does adding more files affect the time to upload content?
Analyze the time complexity of the following operation sequence.
aws s3 mb s3://my-static-website
aws s3 website s3://my-static-website --index-document index.html
aws s3 cp ./site-content/ s3://my-static-website/ --recursive
This sequence creates a bucket, enables website hosting, and uploads all website files to S3.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Uploading each file to the S3 bucket.
- How many times: Once per file in the website content folder.
As you add more files, the number of upload operations grows directly with the number of files.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 uploads |
| 100 | 100 uploads |
| 1000 | 1000 uploads |
Pattern observation: The number of uploads grows linearly as you add more files.
Time Complexity: O(n)
This means the time to upload and host your website grows directly in proportion to the number of files you have.
[X] Wrong: "Uploading more files won't affect the time much because S3 is very fast."
[OK] Correct: Even though S3 is fast, each file upload is a separate operation, so more files mean more time spent uploading.
Understanding how operations scale with input size helps you design efficient cloud workflows and explain your reasoning clearly in interviews.
"What if we used a single large file instead of many small files? How would the time complexity change?"