首页 > 解决方案 > 人为限制 celery worker 可用的内存

问题描述

我有一个(我认为相当标准的)设置,带有 Django 服务器 + redis + celery。

根据委派给芹菜工人的任务,有时我会得到:

[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).

据我所知,工人被杀死是因为系统内存不足。

我希望能够在测试环境中模拟该问题。如何人为地限制芹菜工人(或所有工人)可用的内存或模拟工人以这种方式退出?

标签: pythondjangoout-of-memorycelery

解决方案


推荐阅读