Google App Engine HRD - what if I exceed the 1 write per second limit for writing to the entity group?

拈花ヽ惹草 提交于 2019-11-29 04:22:37

one write per second is a little low. it actually supports more than that. i would even say between 5 and 10 writes per second but i can't guarantee that of course.

if you hit that limit you will get an exception yes. the exception message will be:
Too much contention on these datastore entities. please try again.

but i don't know/remember the exact Exception that will raise.

you have the choice to retry, continue or whatever else you think is right to to at that point.

you can't tell if you are close to a 1 write per second limit. it happens and you deal with it.

Based on the GAE documentation and from my limited experience:

  1. Expect something like 1 QPS rate and tune your app accordingly.
  2. Sharding is a common pattern to handle datastore contention.
  3. Always add defensive code to handle every possible exception (Application Error 5, The datastore operation timed out, Transaction collision for entity group, ..)
  4. In case of error, retry the write moving the task in a proper taskqueue or, if you can, just alert the user to try again.
  5. Retrying a write, usually works.
  6. When possible, use a write-behind cache mechanism moving the writes operation that can lead to contention to Memcache and a Taskqueue slowing down the datastore hit rate.
  7. A good way to avoid contention is to keep the entity groups small, but don't count on it too much.
  8. You can have contention even on single entity.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!