Firestore 500+ Writes Per Second to One Collection

随声附和 提交于 2019-12-08 05:44:36

问题


Firestore has a limit of 500 writes per second to

"a collection in which documents contain sequential values in an indexed field"

https://cloud.google.com/firestore/quotas#writes_and_transactions

What scenarios can I increase the limit to 10,000 writes per second in ONE collection?

Assuming I use Best Practices of keeping Document IDs distributed relatively evenly throughout the key range.

A) What if the documents do not contain any sequential values?

E.g. the only fields I have in each document is below.

  • Field A: random string
  • Field B: random string

B) What if the document contains a sequential field, but I don't query by that field ever?

  • Field A: random string
  • Field B (Sequential): date

C) What if the document contains a sequential field, but I turn off indexing to the date in Field B?

  • Field A: random string
  • Field B (Sequential): date (automatic indexing turned off)

C) Part 2 - If I turn off indexing to that date field (and this removes the 500 per second limitation), what happens if I randomly add a Field C to a SINGLE document in the collection? Does having this one document with a Field C ruin the 10,000 per second write limitation to the collection? Because now Firestore has to worry about automatic indexing of any new Field C?

(and then does this happen every single time you add a random field to any document in this collection, and therefore have to turn off indexing to every possible field in the collection to remove the 500ps limitation?)


回答1:


500 writes per second is a conservative estimate of what a single server can handle. As Cloud Firestore does horizontal row sharding for both document and index storage; this means documents written with sequential ids, or index entries being added sequentially will be handled by a single server. Putting these together (500 writes per server + sequential updates handled by 1 server) is what gives you that limit.

When you have well distributed data, our horizontal row sharding can split for workload into many servers. For Cloud Firestore in Native mode, this will work until you hit the upper limit of our realtime system, which is around 10K writes/second. For Cloud Firestore in Datastore mode, there is no practical limit as long as you give us a heads up (customers can exceed 1M writes/second)

In short, A) and C) will be limited by the upperbound of the mode (10K or available capacity). B) will be limited by the load a single server can handle.

For C2), there will be no impact if you are just adding it to a single document. The limit is purely based on the incoming load and what servers it gets assigned to.



来源:https://stackoverflow.com/questions/55818648/firestore-500-writes-per-second-to-one-collection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!