amqp-node / amqplib

AMQP 0-9-1 library and client for Node.JS

Home Page:https://amqp-node.github.io/amqplib/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CPU intensive controller prevents AMQP connection from receiving heartbeat, hence connections gets closed.

ticmaidev opened this issue · comments

I've reported this issue on NestJS, so here's the link for reference (includes minimum reproduction code):

nestjs/nest#13040

Hi @ticmaidev

This is a consequence / limitation of the Node.js architecture. If you have a long running synchronous task, or you flood the event loop with a high number of asynchronous ones, new tasks may not be executed for quite some time.

In the case of amqplib, this means that it may neither be able to send nor receive heartbeats, and may either close the connection, or have it closed by the broker.

You options are to

  1. Disable heartbeats (which must currently be done on the broker and client), instead relying on tcp keepalive
  2. Move the CPU intensive work to a background process see here and here
  3. Throttle the workload
  4. Scale your services to meet workload

THANK YOU