ayeo-flex-org / pulsar-flex

Pulsar Flex is a modern Apache Pulsar client for Node.js, developed to be independent of C++.
MIT License
45 stars 9 forks source link

Consumer can't keep up, leading to memory leak #77

Closed sOfekS closed 2 years ago

sOfekS commented 2 years ago

Describe the bug Consume on high throughput sturggles to keep up and eventually leads to memory usage rising until crashing

Reproduce

  1. Run a consumer that subscribes to that topic and logs each topic offset
  2. Run a producer that continuously produces messages to a topic at 5MB/s (split between 70-100 messages per second)
  3. After a certain amount of time (for me around 10/15 minutes) memory usage starts rising rapidly and the subscription's backlog size also rises steadily. Expected behavior I expect the consumer to be able to handle these kinds of throughput and keep up with the consumer with memory usage staying steady.

Observed behavior Every time the dequeue function is called, I logged the length of receiveQueue. At some point, it barely manages to empty the queue, reaching thousands of messages rapidly (even though I set receiveQueueSize to 1000). This can be seen even within seconds if the consumer starts with a few thousand messages in its backlog.

Environment: