Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery. Decrease number of processes

Is there any way around to limit number of workers in celery? I have small server and celery always creates 10 processes on 1 core processor. I want to limit this number to 3 processes.

like image 565
Nikolay Fominyh Avatar asked Aug 31 '12 10:08

Nikolay Fominyh


People also ask

What is soft time limit in celery?

Celery worker is set to timeout after 10 seconds with soft timeout of 5 seconds. A delay is introduced to the celery task in order to cause a timeout. The timeout Exception is never raised by Celery worker.

Is celery persistent?

Queues created by Celery are persistent by default. This means that the broker will write messages to disk to ensure that the tasks will be executed even if the broker is restarted.

What is concurrency in celery?

As for --concurrency celery by default uses multiprocessing to perform concurrent execution of tasks. The number of worker processes/threads can be changed using the --concurrency argument and defaults to the number of available CPU's if not set.


1 Answers

I tried setting concurrency to 1 and max_tasks_per_child to 1 in my settings.py file and ran 3 tasks at the same time. It just spawns 1 process as a User and the other 2 as celery. It should should just run 1 process and then wait for it to finish before running the other one.

I am using django celery.

EDIT {

I was assigning concurrency by writing CELERYD_CONCURRENCY = 1 in settings.py file. But when I looked at the celery log file using "tail -f /var/log/celery/w1.log" then I saw a value of 8 assigned to concurrency. This told me that setting.py does not change the concurrency. To fix this issue I added the following lines to "/etc/default/celeryd" file.

# Extra arguments to celeryd
CELERYD_OPTS="--concurrency=1"

Now the second task in the queue waits until the first is finished.

}

like image 83
fatrock92 Avatar answered Sep 21 '22 19:09

fatrock92