我有一個以RabbitMQ作爲代理的基於Celery的任務隊列。我每天處理大約100封郵件。我沒有設置後端。Celery和RabbitMQ最終因內存耗盡而停止
我開始任務主這樣的:
broker = os.environ.get('AMQP_HOST', None)
app = Celery(broker=broker)
server = QueueServer((default_http_host, default_http_port), app)
...我開始喜歡這個工人:
broker = os.environ.get('AMQP_HOST', None)
app = Celery('worker', broker=broker)
app.conf.update(
CELERYD_CONCURRENCY = 1,
CELERYD_PREFETCH_MULTIPLIER = 1,
CELERY_ACKS_LATE = True,
)
服務器正常運行了相當一段時間,但經過約兩幾個星期它突然停止。我已經跟蹤停止下來的RabbitMQ不再接收由於內存耗盡消息:
Feb 25 02:01:39 render-mq-1 docker/e654ac167b10[2189]: vm_memory_high_watermark set. Memory used:252239992 allowed:249239961
Feb 25 02:01:39 render-mq-1 docker/e654ac167b10[2189]: =WARNING REPORT==== 25-Feb-2016::02:01:39 ===
Feb 25 02:01:39 render-mq-1 docker/e654ac167b10[2189]: memory resource limit alarm set on node [email protected]
Feb 25 02:01:39 render-mq-1 docker/e654ac167b10[2189]: **********************************************************
Feb 25 02:01:39 render-mq-1 docker/e654ac167b10[2189]: *** Publishers will be blocked until this alarm clears ***
Feb 25 02:01:39 render-mq-1 docker/e654ac167b10[2189]: **********************************************************
問題是我無法弄清楚需要進行不同的配置如何防止這種疲憊。顯然某處沒有被清除,但我不明白。
例如,約8天后,rabbitmqctl狀態顯示我:
{memory,[{total,138588744},
{connection_readers,1081984},
{connection_writers,353792},
{connection_channels,1103992},
{connection_other,2249320},
{queue_procs,428528},
{queue_slave_procs,0},
{plugins,0},
{other_proc,13555000},
{mnesia,74832},
{mgmt_db,0},
{msg_index,43243768},
{other_ets,7874864},
{binary,42401472},
{code,16699615},
{atom,654217},
{other_system,8867360}]},
...當它第一次開始了它要低得多:
{memory,[{total,51076896},
{connection_readers,205816},
{connection_writers,86624},
{connection_channels,314512},
{connection_other,371808},
{queue_procs,318032},
{queue_slave_procs,0},
{plugins,0},
{other_proc,14315600},
{mnesia,74832},
{mgmt_db,0},
{msg_index,2115976},
{other_ets,1057008},
{binary,6284328},
{code,16699615},
{atom,654217},
{other_system,8578528}]},
...即使所有隊列爲空(除一個作業目前正在處理):
[email protected]:/# rabbitmqctl list_queues -q name memory messages messages_ready messages_unacknowledged
celery 61152 1 0 1
[email protected] 117632 0 0 0
[email protected] 70448 0 0 0
celeryev.17c02213-ecb2-4419-8e5a-f5ff682ea4b4 76240 0 0 0
celeryev.5f59e936-44d7-4098-aa72-45555f846f83 27088 0 0 0
celeryev.d63dbc9e-c769-4a75-a533-a06bc4fe08d7 50184 0 0 0
我不知所措弄清楚如何到FI找出內存消耗的原因。任何幫助將不勝感激。
看來你的隊列(S)(或交換機)正在進入流動狀態。您能否檢查一下 - 它在rabbitmq Web UI中可見 – cantSleepNow
此特定服務器沒有安裝或配置Web UI。有沒有簡單的方法來使用rabbitmqctl或其他命令行工具來查找這些信息?另外,從閱讀[理解流量控制](http://www.rabbitmq.com/blog/2014/04/14/finding-bottlenecks-with-rabbitmq-3-3/),我不確定這是什麼因爲描述意味着服務器無法跟上傳入的連接,但請求從來沒有超過每分鐘3-4次。 – seawolf
我不知道命令行...是的,流意味着發行商對於服務器來說太快了,這也可以解釋爲消費者在處理消息時速度太慢,但最終似乎只有出版商纔會這樣做。 https://www.rabbitmq.com/memory.html – cantSleepNow