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

自古美人都是妖i 提交于 2019-11-27 18:15:52

问题


According to the Google App Engine documentation, writing to one entity group is limited to one write per second when using High Replication Datastore. So...

  1. What happens if I exceed this limit? Some kind of exception? And what should I do?
  2. How do I know that I'm close to exceeding this limit? I can design the application in a way that particular actions (adding an entity...) are not likely to happen often but naturally I can't guarantee that.

回答1:


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.




回答2:


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.


来源:https://stackoverflow.com/questions/10454467/google-app-engine-hrd-what-if-i-exceed-the-1-write-per-second-limit-for-writin

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