数据存储写入限制测试 - 试图破坏应用引擎,但不会中断;) [英] Datastore write limit tests - trying to break app engine, but it won´t break ;)
问题描述
我们试图测试提到的写入限制例外约为每秒1次写入代码( https://developers.google.com/appengine/docs/python/datastore/exceptions - >超时)
We´re trying to test the write limit exceptions mentioned to be about 1 write / second to prep our code for it (https://developers.google.com/appengine/docs/python/datastore/exceptions -> Timeout)
所以我正在创建一个项目,并通过任务循环计数10k次并通过循环更新10k次......尽管每秒写入次数应该足够高,但似乎并未触发异常(我记得一些事情就像每秒写入一个以上的数据一样重要)。
So I´m creating a item and updating it with the loop count 10k times via tasks and 10k times via a loop... It doesn´t seem to trigger a exception although the writes per second should be high enough (I remember something like more than one write per second gets critical).
总是一样的:当你想要它们时,事情不会中断;)。
Always the same: things don´t break when your´re you want them to ;).
class Message(ndb.Model):
text = ndb.StringProperty()
count = ndb.IntegerProperty()
#defined in seperate file
class DeferredClass(object):
def put(self, id, x):
msg = Message.get_by_id(id)
msg.count = x
try:
msg.put()
except:
logging.error("error putting the Message")
logging.error(sys.exc_info()[0])
msg = Message(text="TestGreeting", count=0)
key = msg.put()
id = key.id()
test = DeferredClass()
for x in range(10000):
deferred.defer(test.put, id, x)
for x in range(10000):
msg.count = x
try:
msg.put()
except:
logging.error("error putting the Message")
logging.error(sys.exc_info()[0])
self.response.out.write("done")
PS:我们知道文档是用于db的,代码是ndb ...基本的限制应该仍然存在...另外:关于ndb Exceptions的Docs会很棒!任何人?
PS: We´re aware that the docs are for db and the code is ndb... the basic limitations should still exist... Also: Docs on ndb Exceptions would be great! Anyone?
推荐答案
使用一个非默认的TaskQueue,速度上限为350 / tasks / sec,导致20个实例被解雇以及大量的超时例外......感谢Mr.Steinrücken!
Using a non-default TaskQueue with a increased rate limit of 350/tasks/sec led to 20 instances being fired up and plenty of Timeout Exceptions... Thanks Mr. Steinrücken!
例外情况是google.appengine.api.datastore_errors.Timeout,这与记录的db包 - 所以没有ndb extras。
The Exception is google.appengine.api.datastore_errors.Timeout, which is the same as documented for the db package - so no ndb extras there.
PS:我们的想法是捕获缓存处理类中的异常,作为数据存储过载的标志,并自动为该项目...监视任务一分钟,并在不需要时再次进行阴影...
PS: Our idea is to catch the exception in our cache handling class as a sign of datastore overload and automatically set up shading for that item... monitoring the quests a minute and diable shading again when not needed...
这篇关于数据存储写入限制测试 - 试图破坏应用引擎,但不会中断;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!