Hosting setup and deployment in Firebase - Time & Space Complexity
When setting up and deploying hosting on Firebase, it's important to know how the time to complete these steps changes as your project grows.
We want to understand how the deployment process scales with the size of your website or app files.
Analyze the time complexity of deploying a website using Firebase Hosting CLI.
firebase login
firebase init hosting
firebase deploy --only hosting
This sequence logs in, initializes hosting setup, and deploys the website files to Firebase Hosting.
Look at what happens multiple times during deployment.
- Primary operation: Uploading each file from your project to Firebase servers.
- How many times: Once per file in your website or app folder.
As you add more files, the deployment takes longer because each file is sent separately.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 files | About 10 upload operations |
| 100 files | About 100 upload operations |
| 1000 files | About 1000 upload operations |
Pattern observation: The number of upload operations grows directly with the number of files.
Time Complexity: O(n)
This means the deployment time grows in a straight line with the number of files you have to upload.
[X] Wrong: "Deploying takes the same time no matter how many files I have."
[OK] Correct: Each file must be uploaded separately, so more files mean more upload steps and longer deployment.
Understanding how deployment time grows helps you plan and explain your cloud workflows clearly, a useful skill in real projects and discussions.
What if Firebase used batch uploading to send multiple files at once? How would the time complexity change?