Firestore - Write rate limit per document

1,248 views
Skip to first unread message

Paulo Ricardo

unread,
Jul 11, 2018, 10:39:41 PM7/11/18
to Firebase Google Group
Hi,

According to the Firestore documentation, we can only update a document about once per second.

It seems possible to go over this limit though. In a test enviroment, I had 24 users accounts (bots) simultaneously writing to the same document 3 times per second each. I had no crashes at all. And I could watch the updates happening from the console.

At this point, it is clear that this limit is not hard coded, but some fundamental system limitation that we should be aware of. Which means I can't simply cross the line without being aware of the risks.

Could you please help me to understand this limitation better? Why was I able to fire such high write limit without crashes? Does it have anything to do with the size of the collection, or de index, or with the general write rate on the collection?

Thank you.

Samuel Stern

unread,
Jul 12, 2018, 12:02:53 PM7/12/18
to fireba...@googlegroups.com
Hi Paulo,

You're correct that the limit is not hard coded.  1 QPS writes per document is just the maximum limit for sustained writes that we expect to always work.  If you do a quick burst of 5, 10, or even 50 writes in one second we can handle it by simply queuing the writes and executing them one by one.  So for example in a social networking app, you wouldn't see any errors if two users "liked" a post at the same instant.  However if you keep up high QPS to a single document over a long period of time, you'll eventually exceed the write queue capacity and get errors back from the API.

You're also correct that indexes play a big part in this.  The write is not complete until all relevant index entries have been updated.  So if your document has hundreds of fields and a few dozen compound indexes, each write will take longer and your max QPS writing to that document will get lower until you're at that 1 QPS number.

The main point of publishing that limit is to warn developers not to build an app that depends on achieving sustained writes >1QPS for a single document, because you will almost definitely see some failures.

- Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/891b801f-2bbf-4c6a-9af1-c7259ff5acbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paulo Ricardo

unread,
Jul 12, 2018, 5:45:41 PM7/12/18
to Firebase Google Group
Hi Samuel,

That answers my question. Thank you very much.
Reply all
Reply to author
Forward
0 new messages