Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

celery - will --max-memory-per-child restart workers instantly or allow them to finish the task?

Tags:

Once a worker process crosses the --max-memory-per-child limit, does it get killed and restarted instantly? or does celery allow it to finish the current task (even if it has to consume some more memory while finishing) and then restart it?

like image 666
Martin Massera Avatar asked Jun 09 '17 16:06

Martin Massera


1 Answers

According to my tests, it always lets the task finish even if the task uses much more memory than the limit. This is my test:

  • set the memory limit to 15 MB
  • created a task that:
    • consumes 50 MB sleeps
    • prints memory use, sleeps 30 seconds
    • consumes 50 MB more
    • prints memory use, sleeps 30 seconds
    • prints memory use, exit

I added the sleeps just in case to give time for celery to kill the task.

In all cases it always allows the task to finish and then the next task starts with zero (If I change the task to consume less memory than the limit, the next task does not start at zero).

like image 127
Martin Massera Avatar answered Sep 30 '22 15:09

Martin Massera