The memory usage is huge on MQTT with cleanSession=false and can not be limited by high water mark (3.12.13) #10627
-
Describe the bugAs showed below, the mqtt reader seems using more than 10MB for each connection, and this memory can not be limited by high watermark setting @ansd
Reproduction steps
wait for running for a while and everything looks ok, until we start a new bench again below, we can see the server memory usage will grow quickly
Expected behaviorShould not use so much memory and the memory used by mqtt should be limited Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 20 replies
-
This topic has been documented for years in Tuning for a Large Number of Concurrent Connections |
Beta Was this translation helpful? Give feedback.
-
This blog post uses very low TCP buffer sizes but for mostly idle connections this should be perfectly fine. Also, the high VM memory watermark does not limit the number of connections. What it does is documented in the Alarms guide. There is a separate mechanism (more than one, in fact) that allows you to limit the number of connections specifically to protect the node from applications that leak connections. |
Beta Was this translation helpful? Give feedback.
-
FWIW, I tried to repro. I deployed a single node (not 5 node) cluster on a Linux box:
with the following
I started clients as follows:
after 2 mins:
Messages flow through the system and memory usage of the broker is kept at only 3.2 GB. |
Beta Was this translation helpful? Give feedback.
So, we found the bottleneck:
queue_master_locator = min-masters
(applicable to classic queues) reads all queue records from the database, which leads to unnecessary high resource usage.In contrast,
queue_leader_locator = balanced
(applicable to quorum queues and streams) provides a better implementation since nodes will be selected randomly when there are more than 1000 queues.queue_master_locator = min-masters
is indeed the default in the cluster-operator.I suggest you use
queue_master_locator = client-local
so that your MQTT clients can consume locally from the node they are connected to.