Android: Firebase realtime database has any connection pooling?

I am using the real time database of Firebase. Below is how I use it.

 private void saveInDatabase(String email)
        // Write a message to the database
        FirebaseDatabase database = FirebaseDatabase.getInstance();
        DatabaseReference myRef = database.getReference("user");
        String key = myRef.push().getKey();

        User user = new User();
        user.setCountry("United States");


Now, here is the thing. In the Firebase console, we can see the "usage" and the "number of simultaneous real time connections". I noticed that this "number of simultaneous real time connections" for me is always 1, whether I have the app in 2 phones, whether I closed the connection with database.goOffline(), or whether I turned off phones.

So how does this really work? Is there any connection pool? According to some of the threads I saw, 1 connection = one device using the connection, in that case if I have 1,000,000 users then I have 1,000,000 connections? I do not believe so!!

1 answer

  • answered 2018-04-14 21:41 Doug Stevenson

    The client SDK maintains a single websocket for all communication to the server side. This connection may be shut down if the app is no longer in use. It is definitely shut down if the app process isn't running, or the browser tab is closed.

    The graph of active connections does not show a perfectly live measurement of the number of active connections. You should only be using this as a general gauge for how much activity your database is getting over time.