What is the difference between
celery -A tasks worker -l info --concurrency=4
And
celery -A tasks worker -l info -n worker1@%h
celery -A tasks worker -l info -n worker2@%h
celery -A tasks worker -l info -n worker3@%h
celery -A tasks worker -l info -n worker4@%h
If celery uses multiprocess by default, in above 2 cases, does it switches to multithread with --concurrency=4
or it steel uses multiprocess.
Also can someone give me advice to scale my celery configuration. I am new in this, for this reason, i wanted to know what kind of configurations i have with celery to use celery in full power.
2
Answers
There is a huge difference between the two.
The command above will start a "Celery worker" (that is how they call it in the documentation – very confusing) in the default (pre-fork) concurrency mode. Celery worker process will spawn four worker-processes that will execute tasks.
However,
will create four Celery worker processes. Each of them will run in the default (pre-fork) concurrency mode, and each will spawn N worker-processes to execute tasks. Now, imagine you run this on machine with N=8 cores. – You will end up with 32 worker-processes!
and
2.
Answer:
They both are used to run the Celery workers but with much difference in their configuration and behavior. Here is a detailed comparison:
1. Using
--concurrency=4
:This starts one worker process with a concurrency of 4. The worker will then create 4 internal worker threads or processes (depending on the configuration of the worker pool) to execute tasks concurrently. Key Points: All tasks are processed by the same worker instance.
2. Starting multiple workers with
-n
:celery -A tasks worker -l info -n worker3@%h
celery -A tasks worker -l info -n worker4@%h