0

I have problem run celery workers to execute same task multiple times in parallel.

I ran 3 workers and set --concurrency to 2 for all workers.

But it only executes 3 tasks over all 3 workers.

I hope to run about 10 workers.

celery -A my_app worker -l info  -c 2 -n worker1
celery -A my_app worker -l info  -c 2 -n worker2
celery -A my_app worker -l info  -c 2 -n worker3

Please help me whether I can run more than 3 tasks at a time.

1
  • You can check autoscale option in celery. Commented Nov 27, 2017 at 4:58

1 Answer 1

1

I solved it by using max-tasks-per-child argument.

Here is my solution.

celery -A my_app worker -l info -c 10 --max-tasks-per-child 10 -n worker1

After running this, it can execute 10 same tasks at a time in parallel.

Hope this is helpful.

Sign up to request clarification or add additional context in comments.

1 Comment

The --max-tasks-per-child setting has nothing to do with parallel execution of tasks. It specifies how many tasks a child process executes before it is killed and replaced with a new process. The option -c 10 is what specifies the number of child processes, and hence the number of parallel tasks that can run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.