0
0
Firebasecloud~5 mins

Why social login improves conversion in Firebase - Performance Analysis

Choose your learning style9 modes available
Time Complexity: Why social login improves conversion
O(n)
Understanding Time Complexity

We want to understand how adding social login affects the number of operations in Firebase authentication.

Specifically, how does the work grow when more users use social login?

Scenario Under Consideration

Analyze the time complexity of the following Firebase social login process.


const provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider)
  .then((result) => {
    const user = result.user;
    // Save user info to database
    return firebase.firestore().collection('users').doc(user.uid).set({
      name: user.displayName,
      email: user.email
    });
  });
    

This code lets a user sign in with Google and then saves their info to the database.

Identify Repeating Operations

Identify the API calls, resource provisioning, data transfers that repeat.

  • Primary operation: signInWithPopup call to authenticate user via Google.
  • How many times: Once per user login attempt.
  • Secondary operation: Writing user data to Firestore database.
  • How many times: Once per successful login.
How Execution Grows With Input

Each new user triggers one authentication and one database write.

Input Size (n)Approx. Api Calls/Operations
1010 signInWithPopup + 10 database writes = 20 operations
100100 signInWithPopup + 100 database writes = 200 operations
10001000 signInWithPopup + 1000 database writes = 2000 operations

Pattern observation: Operations grow directly with the number of users logging in.

Final Time Complexity

Time Complexity: O(n)

This means the work grows linearly as more users use social login.

Common Mistake

[X] Wrong: "Social login reduces operations to constant time regardless of users."

[OK] Correct: Each user still triggers separate authentication and database writes, so operations increase with users.

Interview Connect

Understanding how user actions translate to backend operations helps you design scalable systems and explain trade-offs clearly.

Self-Check

What if we cached user data locally after first login? How would that affect the number of database writes and overall time complexity?