Artificially limit memory available for celery worker

Viewed 1294

I have a (what I think fairly standard) setup with a Django server + redis + celery.

Depending on the task being delegated to the celery worker, sometimes I get:

[2020-07-21 19:58:17,401: ERROR/MainProcess] Process 'ForkPoolWorker-1' pid:31695 exited with 'signal 9 (SIGKILL)'
[2020-07-21 19:58:17,469: ERROR/MainProcess] Task handler raised error: WorkerLostError('Worker exited prematurely: signal 9 (SIGKILL).',)
Traceback (most recent call last):
  File "/path/to/venv/lib/python3.6/site-packages/billiard/pool.py", line 1267, in mark_as_worker_lost
    human_status(exitcode)),
billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 9 (SIGKILL).

From what I can tell, the worker is being killed because the system ran out of memory.

I would like to be able to simulate that problem in a testing environment. How can I artificially limit the memory available to a celery worker (or all workers) or simulate a worker exiting this way?

0 Answers
Related