skip to Main Content

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


  1. Does this mean that subcollections are considered collections?

    Subcollections are considered independent collections with their own indexes.

    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?

    No. Each subcollection is considered independently.

    Furthermore, does this also affect firestore’s serverTimestamp method?

    Yes, they are considered to be sequential. This is covered in the documentation:

    If you index a field that increases or decreases sequentially between documents in a collection, like a timestamp, then the maximum write rate to the collection is 500 writes per second. If you don’t query based on the field with sequential values, you can exempt the field from indexing to bypass this limit.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search