I am a bit confused on the rate soft rate limit of 500 to a firestore collection in which documents contain sequential values in an indexed field. Does this mean that subcollections are considered collections? For example, if I was expect 100 writes per second(with indexed fields being sequential) to 10 subcollections of 1 top level collection, would I be hitting the rate limit on the top level collection?
Furthermore, does this also affect firestore’s serverTimestamp method? For example, in a chat like app with a single collection to store all the messages, I could see over 500 messages sent per second happening.
https://firebase.google.com/docs/firestore/quotas#writes_and_transactions
2
Answers
Subcollections are considered independent collections with their own indexes.
No. Each subcollection is considered independently.
Yes, they are considered to be sequential. This is covered in the documentation:
The soft write rate limit is caused by physical limits to writing data in close proximity to disk. There is simply a limit to how much data can be written to a part of the disk in a certain timespan.
When considering collections, the limits apply separate to each collection, as each collection is stored in a separate area of the storage.
But you should always consider indexes too, as each index (like each collection) is stored in a certain area of the disk, and writes to the same index thus will cause hotspots in that area. For this reason, regular collection indexes align with the limits of the collection they’re applied to, but collection group indexes actually cause hotspots on the entire group of collections they’re indexing.