celery.node icon indicating copy to clipboard operation
celery.node copied to clipboard

Worker consumes multiple tasks at the same time

Open harryct229 opened this issue 5 years ago • 3 comments

Description

Worker consumes multiple tasks at the same time when other jobs is not done yet.

  • What is the current behavior? Worker consumes multiple tasks at the same time.

  • What is the expected behavior? Worker consumes 1 task at the same time.

  • Please tell us about your environment:

    • Version: 0.5.0
    • OS: [Linux]
    • Language: [ES6/7]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc) So my worker is setup like this:

const testing_work = async (period) => {
  try {
    await someWork(period);
  } catch (err) {
    console.log(err);
    return err;
  }
  return null;
}

const worker = celery.createWorker(
  process.env.CELERY_BROKER, 
  process.env.CELERY_BACKEND,
  "testing_work"
);

worker.register("testing_work", async (period) => {
  try {
    await testing_work(period);
  } catch (err) {
    console.log(err);
    return err;
  }

  return null;
});
worker.start();

harryct229 avatar Nov 19 '20 07:11 harryct229

Hi. Thank you for reporting the bug.

As I see, you want to consumes 1 task at a time so that let the worker run synchronously. But unfortunately, we have not considered synchronous configuration.

I'll try to think about it in the future.

actumn avatar Dec 04 '20 16:12 actumn

Hi @actumn, sorry about the confusion. What I mean is do we have a limit of concurrence jobs. Because right now, the worker can consume all the resources while running all jobs at the same time. In Python celery, we have an option for --autoscale 3,2. Do we have this for JS version?

harryct229 avatar Dec 12 '20 18:12 harryct229

it's not just a bug lack of synchronization (the ability to run only one worker) destroys the meaning of existence of celery in this universe

alexio777 avatar Mar 21 '22 06:03 alexio777