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

worker.concurrency === undefined #1552

Closed
0x7357 opened this issue Nov 28, 2022 · 9 comments
Closed

worker.concurrency === undefined #1552

0x7357 opened this issue Nov 28, 2022 · 9 comments

Comments

@0x7357
Copy link

0x7357 commented Nov 28, 2022

https://docs.bullmq.io/guide/workers/concurrency

I cannot set the "concurrency" as described in the documentation. However, I can set the "concurrency" when I change worker.opts.concurrency.

Is this the way it is supposed to be?

@0x7357
Copy link
Author

0x7357 commented Nov 28, 2022

I would like to achieve that when the worker is restarted, it does not immediately use the full "Concurrency" and thus generates quite a CPU load. Seen like this: A soft-increase, up to the desired limit.

const worker = new Worker("worker", () => {}, {
  concurrency: 1
});

const increaseWorkerConcurrencyInterval = setInterval(() => {
  if (!worker.opts.concurrency) { return; }

  worker.opts.concurrency++;  

  if (worker.opts.concurrency >= 50) {
    clearInterval(increaseWorkerConcurrencyInterval);
  }
}, 1000 * 5);

@manast
Copy link
Contributor

manast commented Nov 28, 2022

So what is the issue you have exactly?

@0x7357
Copy link
Author

0x7357 commented Nov 28, 2022

The documentation says worker.concurrency, but concurrency is undefined in that case. And I wanted to know if it is intentional and the documentation has not been updated yet?

@manast
Copy link
Contributor

manast commented Nov 28, 2022

The documentation says:

worker.concurrency = 5

is it not working?

@0x7357
Copy link
Author

0x7357 commented Nov 28, 2022

Exactly. It doesn't work like that. worker.concurrency is undefined. However, I can set the concurrency via worker.opts.concurrency.

@manast
Copy link
Contributor

manast commented Nov 28, 2022

Are you sure it is not working? We have tests that suggest it works:
https://github.com/taskforcesh/bullmq/blob/master/tests/test_worker.ts#L1530

@0x7357
Copy link
Author

0x7357 commented Nov 28, 2022

I tried worker.concurrency = 5 and it stays, for whatever reason, at 1. However, if I change that via opts.concurrency then everything works. Of course, I may be the problem and am too stupid for this - in which case we can close the question here. :-D

@manast
Copy link
Contributor

manast commented Nov 28, 2022

Just write a test case that shows it is not working and we will look into it. The tests we have are working, so something you do is different from the current test cases.

@0x7357
Copy link
Author

0x7357 commented Nov 28, 2022

It's working with worker.concurrency, too. I don't know what I've done wrong. Sorry for wasting your time.

@0x7357 0x7357 closed this as completed Nov 28, 2022
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