Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery command line parameter for number of worker processes when using gevent

Tags:

python

celery

For multiprocessing pool, I could using the paramter '-c' to specify the number of worker processes. As the folloing shows.

celery worker -A celerytasks.celery_worker_init -c 5 --loglevel=info

But for gevent pool, the paramter '-c' is used to specify greenlet number. How can start multiple worker processes?

Or if I have to start mulitple wokers instead of one worker with multiple processes, could I do that with one command?

like image 435
Jcyrss Avatar asked Sep 10 '25 13:09

Jcyrss


1 Answers

This command will run 1 worker with 5 pool processes. This means you have one worker able to execute 5 task at the time.

If you use gevent the only difference is that celery will use green threads instead of prefork to execute this tasks, but pay attention to the implication of this that you can read here (it's about eventlet but same concepts apply).

If you want to run multiple workers with different parameters (queue, concurrency) thant you need to use the celery multi command:

celery multi start 3 -c 3 -c:1 10
celery worker -n celery1@myhost -c 10
celery worker -n celery2@myhost -c 3
celery worker -n celery3@myhost -c 3
like image 90
Mauro Rocco Avatar answered Sep 13 '25 02:09

Mauro Rocco