简体   繁体   中英

Cloud (Firestore) Datastore Hotspotting and Indexing Date

I have tried to research this topic a lot lately, regarding the hotspotting behavior of Cloud Datastore. As I understand, reading/writing to indexed fields that are monotonically increasing can lead to contention and degradation of performance during high read/write load.

Now, how is it with regards to fields that increase monotonically but on a more coarse level. Take for instance a kind that represent a log of events. If each event has a date field corresponding to the day at which it occurred, such that one can query on a day to day basis. In this case the field will remain constant (not monotonically increasing) until the subsequent day. Will this lead to contention similarly to using a high precision timestamp during a high write load?

For your question:

I am not thinking of using a timestamp, which would increase from entity to entity, but rather a field that is fixed on a day-to-day basis.

According to this "If your app doesn't use the timestamp field in any queries, you can remove the 500 writes per second limit by not indexing the timestamp field." To add in this:

If each event has a date field corresponding to the day at which it occurred, such that one can query on a day to day basis.

If your entities/keys share a common date prefix, but have a completely random suffix, then old tablets (with old date prefixes) won't share the load. For instance, if you want to query for entries by timestamp but only need to return results for a single user at a time, you could prefix the timestamp with the userId and index that new property instead.

Lastly, if you are looking to add a timestamp/day property, and index it, this approach seems to encounter hotspotting.

For more reference, you can look up: High read/write rates to a narrow key range

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM