本文介绍了Beanstalkd中的队列/管道的优先级是否可行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于工作或队列/管理层面的优先级是否有效,我有点困惑。我问的原因是我在Drupal中使用了一个beanstalkd集成模块。该模块可以定义队列/管道,并为创建的每个队列/管道分配一个优先级值。



我正在努力解决的是以下几点。假设我在Beanstalkd(队列A和队列B)中有两个队列/管。如果分配给队列A的项目的优先级高于队列B中的项目,那么这意味着排队B中的项目只会在队列A为空时才被处理?

解决方案

优先级是每个职位,您可以在以下位置阅读更多信息:



没有工作优先级,beanstalkd操作作为FIFO队列。



有三个重要的事实可以了解工作优先级:




  • 优先级较低的作业在优先级较高的作业之前保留。

  • beanstalkd优先级是32位无符号整数(范围从0到2 ^ 32 - 1) / li>
  • beanstalkd使用2 ^ 31作为默认作业优先级(beanstalkd.DEFAULT_PRIORITY)(客户端可能会覆盖此,我看到默认设置为1024)。



另请注意,在同一个内优先级作业仍然以FIFO方式处理。所以如果你有一个在多个管子上观察的代理,当你在这些管上获得相同的优先权时,他们将以FIFO的方式保留。



你可以看管


的工作

I am a little confused as to whether priorities work at the job or queue/tube level. The reason I ask is that I am using a beanstalkd integration module in Drupal. This module enables one to define queues/tubes and assign a priority value to each queue/tube created.

What I am trying to work out is the following. Let's say I have two queues/tubes in Beanstalkd (queue A and queue B). If items assigned to Queue A have a higher priority than items in Queue B, does that mean items in Queue B will only be processed when Queue A is empty?

解决方案

Priorities are per jobs, you can read more about this at: https://github.com/kr/beanstalkd/blob/master/doc/protocol.txt

Without job priorities, beanstalkd operates as a FIFO queue.

There are three hard facts to know about job priorities:

  • Jobs with lower priority numbers are reserved before jobs with higher priority numbers.
  • beanstalkd priorities are 32-bit unsigned integers (they range from 0 to 2^32 - 1).
  • beanstalkd uses 2^31 as default job priority (beanstalkd.DEFAULT_PRIORITY) (the client may override this, I've seen defaults set to 1024).

Note also that within the same priority jobs are still handled in a FIFO manner. So if you have an agent that watches on multiple tubes, and when you get same priority jobs on those tubes they will get reserved in FIFO manner.

You can watch the tubes and jobs with https://github.com/ptrofimov/beanstalk_console

这篇关于Beanstalkd中的队列/管道的优先级是否可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 18:27