我对使用队列执行任务感到困惑。我已经阅读了文档,我想我了解bucket_的大小和速率,但是当我将20个任务发送到一个设置为5/h、大小为5的队列时,所有20个任务都会以最快的速度逐个执行,在不到1分钟内完成。在
deferred.defer(spam.cookEggs,
egg_keys,
_queue="tortoise")
- name: tortoise
rate: 5/h
bucket_size: 5
我想要的是无论我创建10个还是100个任务,我只希望每小时运行5个任务。所以要完成20个任务大约需要4个小时。我要把他们的死刑分散开来。在
问题是,我假设在本地运行时,任务执行率规则是遵循的,但事实并非如此。不能在本地测试执行率。当我部署到生产环境中时,我设置的速率和bucket大小如我所预期的那样执行。在
app_devserver不考虑执行率。生产中不应出现此问题。在
[答案由Nick Johnson和/或问题作者发现;以社区wiki的形式发布在这里,以便我们可以标记为已接受的内容]
您希望将
bucket_size
设置为1,否则您将出现“突发”的排队活动,就像您在那里看到的那样。在从documentation:
相关问题 更多 >
编程相关推荐