Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the number of users ( not logged out ) on app equal no of simultaneous connections on firebase?

I have an android app developed and I am expecting more than a 100 users.The app does have a logout button but I doubt any user would logout,they would instead push it to background. So my question is if I have 150 users ( logged in ,but in background) mean that I have 150 simultaneous connections ? I did read a few questions on simultaneous connections , but can someone be more accurate on what is a concurrent connection. 150 users - logged in (background) - open app at different times - ? If this is going to exceed the free plan on firebase , how do i prevent it?.I use email/password for login.

like image 400
Sandhya Krishnan Avatar asked Mar 29 '17 11:03

Sandhya Krishnan


1 Answers

When you start an app that uses the Firebase Database, it creates a persistent connection to the Firebase server. This counts as one active connection on the back-end.

The connection can be broken when:

  1. the user hasn't written any data and doesn't have any active listeners for a few minutes (currently 5 minutes, but that could change).
  2. you call goOffline() in your code

Whether the app is in the foreground or background is irrelevant to the Firebase SDK. But you could use Android life-cycle events (such as onPause()) to detect such transitions and remove your listeners (to get to condition 1).

Also: when your app is backgrounded, the Android operating system might close the connection from the client to the Firebase back-end at any time. When it does this depends on the version and flavor of Android your device has.

A final option (as fellow Firebaser Doug pointed out in the comments) is to enable automatic resource management. If you enable automatic resource management, the client will essentially call goOffline() when the app goes into the background and goOnline() when it comes back to the foreground.

like image 113
Frank van Puffelen Avatar answered Nov 12 '22 02:11

Frank van Puffelen