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

Clarificaiton regarding concurrency controls #408

Open
salmonsteak1 opened this issue Nov 14, 2024 · 1 comment
Open

Clarificaiton regarding concurrency controls #408

salmonsteak1 opened this issue Nov 14, 2024 · 1 comment

Comments

@salmonsteak1
Copy link

Hey, I'm trying to test out the duration parameter for the limits_concurrency feature. This is how I'm testing it:

# Test
class TestJob < ApplicationSolidqueueJob
  limits_concurrency to: 3, key: "test_job", duration: 2.seconds, group: "TestJob"

  # Infinite loop
  def perform
    sleep 1.second while true
  end
end

I will then run 20 of these jobs, with 10 solid queue workers. I've set concurrency_maintenance_interval to 1 second

From what I can observe, new jobs are being unblocked every 1 second when the dispatcher detects that a worker is running a job longer than the specifiedduration in limits_concurrency.

However, this means that eventually, all my workers will be hogged up by such jobs.

I know that it's possible to counter this by setting a job timeout using this approach, but I just wanted to clarify the usage of the duration value in limits_concurrency.

Given this current behavior, does this mean that this duration value in limits_concurrency refers to how much time the worker has to process this job? If it exceeds this duration, a new job will be unblocked (This is checked by the dispatcher every xxx interval, defined in concurrency_maintenance_interval). Nothing will be done for the worker that is still working on that job?

@rosa
Copy link
Member

rosa commented Nov 14, 2024

Nothing will be done for the worker that is still working on that job?

Yes, that's correct. duration is the time we can guarantee the concurrency controls to take effect. After that passes, jobs will be unlocked.

does this mean that this duration value in limits_concurrency refers to how much time the worker has to process this job?

It doesn't necessarily mean the time a job is running because it might still be waiting to be picked from the queue, for example, if workers are busy with other jobs.

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

2 participants