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.
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:
goOffline()
in your codeWhether 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With