Firebase realtimeDB connected at the same time?

My app is running in the background. If the app is running in the background, is it still connected to realtimeDB at the same time? Or if this application hasn't been using realtimeDB for a while, isn't it considered a simultaneous connection?

If he doesn't care, can I only get 100,000 users?

+3


source to share


2 answers


Your app connects to realtimeDB while yours is active listener

. If you want to stop listening, you need to remove the listener according to your needs and the activity cycle.

For Android

you can use this code in your method onDestroy()

.



databaseReference.removeEventListener(valueEventListener);

      

Hope it helps.

+2


source


I answer your question in three parts in order ..,



  • The Firebase database library manages the connection to your database in the backend and this starts right at the start of the application and it starts to count against your concurrent connections and when that limit reaches the Max Connections limit of 100k bytes any new connection will be dropped until then until the existing connections drop when the app or app is closed, disconnected after a certain timeout or forcibly closing the DB connections by calling

    FirebaseDatabase.getInstance().goOffline()

    However, you can know if a given client is connected or not using a listener in FirebaseDatabase.getInstance().getReference(".info/connected")

    , however it runs locally and does not explicitly connect to the FirebaseDatabase cloud instance, more can be read here

  • Once you implement the aforementioned connection listener, you will see that the SDK manages this dynamically in such a way that connections are automatically disconnected if there are no listeners connected and if there are no DB operations in the application such as .setValue()

    in the last 60 seconds .. but having ValueEventListners will override this and provide continuous communication with the DB. again this can be overridden and the connection can be severed by explicitly callingFirebaseDatabase.getInstance().goOffline()

  • Jump to the maximum concurrent user limit of 100k; as you can see in Firebase Plans

    There is a limit of 100,000 concurrent connections for each flame and flame database. For details, see the section "Prices".

    If you cross this and for scaling you need to increase the limit, you can explicitly ask the Google Firebase team for support and they will handle this on a case-by-case basis so that your app can scale as needed when required.

    What is "concurrent database connection"?

    A concurrent connection is equivalent to one mobile device, browser tab, or server application connected to a database. Firebase limits the number of simultaneous connections to your app. database. These restrictions are in place to protect both Firebase and our users from abuse.

    Spark plane limit is 100 and cannot be raised. Flame and Flame plans have a limit of 100,000 concurrent connections per database. If you require over 100,000 concurrent connections please contact Firebase Support.

    This limit does not match the total number of users in your application, because your users don't all connect at once. We urge you to keep track of the maximum concurrent database connections and update or add more databases as needed.

+2


source







All Articles