如何为sidekiq配置指定不同的并发队列? [英] How can I specify different concurrency queues for sidekiq configuration?

查看:67
本文介绍了如何为sidekiq配置指定不同的并发队列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下sidekiq.yml配置文件,但是我不确定如何构建一个并发性较低的单独队列.我该怎么办?

I have the following sidekiq.yml config file, but I'm not sure how to build a separate queue with lower concurrency. How can I do this?

---
:concurrency: 25
:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:queues:
  - default
  - [high_priority, 2]
  - [import_queue, 3]
  - [user_queue, 4]
:daemon: true

尽管如此,我还是想做些类似的事情,

I would like to do something like the following though,

---
:concurrency: 25
:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:queues:
  - default
  - [high_priority, 2]
  - [import_queue, 3]
  - [user_queue, 4]
:daemon: true
---
:concurrency: 5
:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:queues:
  - small_queue
:daemon: true

推荐答案

并发是Sidekiq进程的一个属性,表示它旋转了多少个线程.您不能使一个Sidekiq进程在两种不同的并发下运行;但是,您可以使用单独的配置文件启动两个Sidekiq进程:

Concurrency is a property of the Sidekiq process, representing how many threads it spins up. You can't have one Sidekiq process operating at two different concurrencies; however, you could spin up two Sidekiq processes with separate config files:

bin/sidekiq -C config/sidekiq_one.yml
bin/sidekiq -C config/sidekiq_two.yml

但是,根据您在这里的动机,您最好只使用一个Sidekiq进程并按优先级对其中的队列进行排序.这样,一个进程中的任何工人都不会闲置,而另一个进程的队列正在增加.虽然视您的情况而定,例如如果第二个队列的工作很少但非常重要,那么这样的解决方案确实有意义.

However, depending on your motivations here, you're likely better off just using one Sidekiq process and ordering your queues within it by priority. That way, no workers in one process are sitting idle while the other process's queue is growing. Though depending on your situation, e.g. if the second queue's jobs are few but very important, such a solution does make sense.

这篇关于如何为sidekiq配置指定不同的并发队列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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