大小为1的任务队列用于串行处理 [英] Task queue of size 1 for serial processing

查看:137
本文介绍了大小为1的任务队列用于串行处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个只有一个任务可以一次处理的串行队列。这是我在queue.xml中的声明:

 < queue> 
<名称>南瓜< / name>
< rate> 20 / s< / rate>
< bucket-size> 1< / bucket-size>
< max-concurrent-requests> 1< / max-concurrent-requests>
< / queue>

rate参数对此设置有任何影响吗?

我希望任务排队并且一次只处理一个任务。

谢谢

解决方案

队列速率和存储区大小不会同时限制任务进程的数量。看到这个答案,它比(当前)官方文档(您可能需要相应地重新访问您的配置): https://stackoverflow.com/ a / 3740846/4495081



但是,您的 max-concurrent-requests 应确保只有一项任务根据文档执行:


您可以通过将max_concurrent_requests设置为
的较低值来避免这种可能性。例如,如果将max_concurrent_requests设置为10,
,则当延迟为0.3
秒时,我们的示例队列维护大约20个任务/秒。但是,当延迟时间超过0.5秒时,此
设置会限制处理速率,以确保不超过10个
任务同时运行。



I want a serial queue where only one task may process at a time. This is my declaration in queue.xml:

<queue>
    <name>pumpkin</name>
    <rate>20/s</rate>
    <bucket-size>1</bucket-size>
    <max-concurrent-requests>1</max-concurrent-requests>
</queue>

Does the "rate" parameter have any effect in this setup?

I want tasks to queue up and only process one at a time.

Thanks

解决方案

The queue rate and bucket size do not limit the number of tasks processes simultaneously. See this answer which captured a (now gone) official explanation of these configs better than the (current) official docs (you may want to revisit your configs accordingly): https://stackoverflow.com/a/3740846/4495081

However your max-concurrent-requests should ensure only one task is executed at a time, according to the docs:

You can avoid this possibility by setting max_concurrent_requests to a lower value. For example, if you set max_concurrent_requests to 10, our example queue maintains about 20 tasks/second when latency is 0.3 seconds. However, when the latency increases over 0.5 seconds, this setting throttles the processing rate to ensure that no more than 10 tasks run simultaneously.

这篇关于大小为1的任务队列用于串行处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆