问题
We recently found a severe limitation of firestore
Maximum write rate to a collection in which documents contain sequential values in an indexed field - 500/sec
Initially, we didn't see it an issue but once we are into development we hit this road block. Let's consider a simple use-case as an example.
Consider a leaderboard for a game where there are 1 Million players. Players will be submitting scores to this leaderboard. At the end of the week/month we want to reward all the participants randomly with virtual currency.
We store the scores for each player in scores collection, and by default it needs to be indexed on score value(which may not be a random number, but more likely a sequential number). In this aspect we hit the 500 write/sec limit.
Time taken to calculate the reward distribution
1,000,000 / 500 writes/sec = 2000 secs = 33.33 minutes!
Cost : $1.8 + 30 mins of function processing time
So for awarding the players, it takes around 2000 secs(33 minutes) to finish the above updates.
Currently we update the above documents through cloud task(as suggested by Doug) but as per the docs cloud task has a limit of 30minutes max processing time (Can split the tasks though to avoid this overhead).
We see it a severe concern as its very likely that every document has a created/updated timestamp which is not a random number and is bounded by this limitation.
What is the next available database on GCP which overcomes the limitations of Firestore and needs to handle traffic from serverless cloud functions?
来源:https://stackoverflow.com/questions/62360116/alternative-for-firestore-on-gcp