Firebase vs AWS vs Supabase comparison - Performance Comparison
When using cloud services like Firebase, AWS, or Supabase, it's important to know how the time to complete tasks grows as you add more data or users.
We want to understand how the number of operations changes when we scale up.
Analyze the time complexity of fetching user data from Firebase.
const db = getFirestore();
const usersRef = collection(db, 'users');
const snapshot = await getDocs(usersRef);
snapshot.forEach(doc => {
console.log(doc.id, '=>', doc.data());
});
This code fetches all user documents from the 'users' collection and processes each one.
Look at what repeats when fetching and processing data.
- Primary operation: Fetching each user document from the database.
- How many times: Once per user document in the collection.
As the number of users grows, the number of documents fetched and processed grows too.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 document fetches |
| 100 | 100 document fetches |
| 1000 | 1000 document fetches |
Pattern observation: The number of operations grows directly with the number of users.
Time Complexity: O(n)
This means the time to fetch and process data grows in a straight line with the number of user documents.
[X] Wrong: "Fetching all users is always fast no matter how many users there are."
[OK] Correct: More users mean more documents to fetch, so the time grows with the number of users.
Understanding how cloud operations scale helps you design apps that stay fast as they grow. This skill shows you can think about real-world app performance.
What if we changed fetching all users to fetching only users with a specific property? How would the time complexity change?