Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sidekiq worker priority setup

Currently am running my background jobs using sidekiq. Concurrently am running 10 jobs at a time. These jobs are not a small jobs. It will take 6-8 hours to complete the work.

In the mean time i need to run some smaller jobs(will take 2-3 mins). Currently am not able to run these jobs until any one of the above 10 jobs to complete. So i need to wait for 6-8 hours to perform this small job.

But these jobs should run immediately after adding to the queue. Is there any option to block any one of the process to run this kind of small jobs. I tried the queue option but its also not working in my scenario.

Here is my sidekiq config

:concurrency: 10
:queues:
  - [web, 7]
  - [default, 3]

Can any one give me the solution for this problem?

like image 496
SaravanaKumAr Avatar asked Apr 07 '14 13:04

SaravanaKumAr


People also ask

How many jobs can Sidekiq handle?

The author of Sidekiq recommends a limit of 1,000 jobs per bulk enqueue and that's the default in the perform_bulk method.

How do you run a worker on Sidekiq?

To run sidekiq, you will need to open a terminal, navigate to your application's directory, and start the sidekiq process, exactly as you would start a web server for the application itself. When the command executes you will see a message that sidekiq has started.

Is Sidekiq multithreaded?

In 2012, Mike Perham was the first to introduce a multi-threading background job system. Resque is multi-process and single-thread. Delayed_job can work ‌for single thread processing only. Sidekiq was the first multi-threading tool in the Ruby community.


1 Answers

The long jobs suffocate the smaller jobs since they fight over the same resources.

I can suggest that you run two sidekiq processes, each using a different config file, and each listening to a different queue:

sidekiq_long.yml:

:concurrency: 10
:queues:
  - default

sidekiq_normal.yml:

:concurrency: 3
:queues:
  - web

This way one sidekiq process will always be available to server short jobs:

sidekiq -C config/sidekiq_long.yml.yml
sidekiq -C config/sidekiq_normal.yml
like image 161
Uri Agassi Avatar answered Oct 13 '22 10:10

Uri Agassi