Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support :backend as a queue_attribute #1163

Open
johnnyshields opened this issue Jan 19, 2022 · 0 comments
Open

Support :backend as a queue_attribute #1163

johnnyshields opened this issue Jan 19, 2022 · 0 comments

Comments

@johnnyshields
Copy link

johnnyshields commented Jan 19, 2022

The Problem

I would like to sub-divide my queues into various database tables. The reason is that I have many types of worker machines each scanning different queues. When Worker A's queue is full (e.g. 100,000 pending jobs) and Worker B's queue is empty, this can happen in my database due to Worker B scanning the table for jobs. (I'm using MongoDB, not SQL)

image

The Fix

DelayedJob currently supports backend and queue_attributes configurations:

# This is currently possible
Delayed::Worker.backend = MyBackendClass

# This is also currently possible
Delayed::Worker.queue_attributes = {
  payments:          { priority: -10 },
  sms:               { priority: -10 },
  push:              { priority: -5 },
  mailers:           { priority: -5, run_delay: 15 },
  ...
}

I would like to support :backend as a queue attribute, like this:

Delayed::Worker.queue_attributes = {
  payments:          { priority: -10 },
  sms:               { priority: -10 },
  push:              { backend: MyBackendClass, priority: -5 },
  mailers:           { backend: MyOtherBackendClass, priority: -5, run_delay: 15 },
  ...
}

(If not specified, it falls back to the base backend configuration)

This way, I can put Worker A and Worker B on separate backends (i.e. separate database tables) and avoid excessive table scanning. This can be thought of as a form of sharding / partitioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant