Search code examples
androidperformancefirebasegoogle-cloud-firestore

Firestore Snapshot Listener. How many can I listen before affect performance


I'm developing a Chat style application that could have many users chatting at the same time. I'm retrieving a list of chat-rooms when I enter on my Home screen and then adding an SnapshotListenerto each one of the chat-rooms to listen the messages in real time. This can grow exponentially and I can end up having hundred or even thousands of SnapshotListener active at the same time on the client side.

My question is, do this affect performance? I mean, regarding Firebase library, it has any kind of limit or performance issue when having that many listeners active at once? Of course not everyone will be chatting at the same time, so even if there are 1000 open listeners, just 5-10 would be chatting and sending callbacks at once.


Solution

  • According to the Best Practices section of the official Firestore documentation:

    You should always try to keep the number of snapshot listeners per client under 100.

    Also you should keep in mind some more generic limits and quotas such as:

    The maximum concurrent connections for mobile/web clients per database = 1,000,000