4
votes

I'm wondering whether there is a maximum number of Firestore realtime listeners I can use, and if there is an overhead per listener?

This is for a page in a React web app. I want to monitor changes in all documents within a collection, so I have the option of either using multiple document listeners, or a single collection query listener. The typical number of documents will be 20-30, but could grow to around 100 for edge cases (I won't be setting a limit, and wouldn't intend on using 'limit()'.

The Firestore architecture is along the lines of:

  /projects/{project}/sections/{section}

Example: A user can edit sections within "project_abc".

I can either setup a single query listener on the 'sections' collection, and then will need to loop through the snapshot (ie multiple docs) on each change, or attach a new document listener to each section (ie. could end up with 30+ listeners).

2

2 Answers

7
votes

All of the documented limits of Cloud Firestore are documented here. Most of the limits are placed on writing of data. The only limit that would affect your specific case is the number of (unique client socket) connections capped at 1 million. The listeners themselves are cheap, and you shouldn't be worried about lots of listeners attached to a document.

2
votes

You might want to think about how you structure your listeners as you say their number could grow to around 100 per client. This would exactly hit the recommended limit as documented in the firebase best practices.