Increasing Preallocated memory

554 views
Skip to first unread message

Marco Lettieri

unread,
Dec 29, 2020, 4:04:53 AM12/29/20
to rabbitmq-users
Hello,
i'm figuring out why on one of my rabbitmq instance the preallocated memory by runtime increase everyday of 50-60MB.
Attached the screenshot of memory detail on just rebooted machine and 6 days uptime.

just booted.png
24h uptime.png
6 days uptime.png
3 days uptime.png

Wesley Peng

unread,
Dec 29, 2020, 4:08:33 AM12/29/20
to rabbitm...@googlegroups.com
what rabbitmq and erlang version you were using?

regards.

Marco Lettieri

unread,
Dec 29, 2020, 4:12:41 AM12/29/20
to rabbitm...@googlegroups.com
RabbitMQ 3.8.9 Erlang 23.1.2 on a Debian 4.9.240-2 virtual machine with 4gb RAM and 4 cores

--
You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/taMFCY0Q9Js/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/019D2EB7-B954-4582-880B-37662B896AC1%40web.de.

Wesley Peng

unread,
Dec 29, 2020, 4:17:10 AM12/29/20
to rabbitm...@googlegroups.com
Is there any error log in the unnormal node?

regards

Marco Lettieri

unread,
Dec 29, 2020, 4:21:20 AM12/29/20
to rabbitmq-users

if you mean  /var/log/rabbitmq/rab...@rabbit01.log i've checked and there are no errors at all

Wesley Peng

unread,
Dec 29, 2020, 4:24:52 AM12/29/20
to rabbitm...@googlegroups.com
any special setup such as DLX, Delayed Message Plugin, backup exchange,  lazy queues?



--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/131ce4e5-4268-45bf-9d6e-7b4635b21bf5n%40googlegroups.com.

Marco Lettieri

unread,
Dec 29, 2020, 4:32:13 AM12/29/20
to rabbitm...@googlegroups.com
none, i have 3 extra topic exchange from default and 386 queue, 9 durable and all other autodelete.
On the 9 durable queues there are about 20/s incoming/get

You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/taMFCY0Q9Js/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/20F186EC-5545-4627-9517-5F9088443162%40web.de.

Marco Lettieri

unread,
Dec 31, 2020, 2:30:21 AM12/31/20
to rabbitm...@googlegroups.com
about 3 days uptime
Schermata 2020-12-31 alle 08.29.16.png
Schermata 2020-12-31 alle 08.25.54.png

Marco Lettieri

unread,
Jan 4, 2021, 3:41:57 AM1/4/21
to rabbitm...@googlegroups.com
seems many durable queues make this issue happen.
deleting unused durable queues the quorum table decrease and the memory increase less, but still increase day by day of about 10-20MB
Attached is 7days uptime
Schermata 2021-01-04 alle 09.41.06.png
Schermata 2021-01-04 alle 09.40.45.png

Karl Nilsson

unread,
Jan 4, 2021, 5:22:15 AM1/4/21
to rabbitmq-users
I see you are using quorum queues, possibly with very low thoughput. Quorum queues will cache the tail of the Raft log in memory until the WAL fills up and and the in-memory entries are flushed to disk. This means quorum queues will consume memory in a saw-tooth pattern (continuous increase until WAL limit is reached after it will drop down). By default the WAL is quite large to deal with high-throughput scenarios but this is configured. Please see: https://www.rabbitmq.com/quorum-queues.html#resource-use for more details.

Cheers
Karl

Marco Lettieri

unread,
Jan 4, 2021, 5:28:09 AM1/4/21
to rabbitm...@googlegroups.com
I guess the durable queues are quorum queues, right?
Because they are the only "special" feature I use. Consider that the durable queues have very low traffic on them, 1-2 messages per hour of 20-30 bytes

Karl Nilsson

unread,
Jan 4, 2021, 5:55:45 AM1/4/21
to rabbitmq-users
ok yeah at that rate it will take a long time to fill the default wal, if you want it to recover memory earlier set a smaller wal size

Marco Lettieri

unread,
Jan 4, 2021, 6:41:10 AM1/4/21
to rabbitm...@googlegroups.com
so this doesn't explain the image above... if quorum (durable) queues have low traffic why does the memory increase?
the wal now is at default size

Karl Nilsson

unread,
Jan 4, 2021, 6:48:38 AM1/4/21
to rabbitmq-users
because every message is written to the WAL _and_ kept in memory, messages are only deleted from the log of operations when the WAL fills up even if they have been removed from the queue. Setting a smaller WAL size will reclaim resources more frequently.

Marco Lettieri

unread,
Jan 4, 2021, 6:56:40 AM1/4/21
to rabbitm...@googlegroups.com
But the documentation said # if quorum queues are not used, configure a lower max WAL segment

https://www.rabbitmq.com/mqtt.html#consensus
Schermata 2021-01-04 alle 12.55.54.png
So is it suggested in my case configure a lower WAL?

Karl Nilsson

unread,
Jan 4, 2021, 7:06:01 AM1/4/21
to rabbitmq-users
From what you've told me you are asking about why the memory increases over time - I explained that it is due to how quorum queues work internally (memory is only reclaimed when the wal file fills up). As your throughput is very low you can safely set a lower WAL size to have the quorum queue related memory reclaimed more often (as the WAL will fill up earlier). Else you can just want for it to happen automatically when it reaches the default WAL size which is around 500MiB of disk use.

Marco Lettieri

unread,
Jan 4, 2021, 7:15:57 AM1/4/21
to rabbitm...@googlegroups.com
sorry, probably something is not clear to me, but if the wal will clear the memory at 512MB doesn't explain why the memory exceeds the memory limit and after 1-2 week the server exceeds high watermark limit.

Karl Nilsson

unread,
Jan 4, 2021, 10:51:33 AM1/4/21
to rabbitmq-users
you never mentioned reaching the memory limit. when you how much does the quorum queue tables memory breakdown use?

Marco Lettieri

unread,
Jan 4, 2021, 11:17:25 AM1/4/21
to rabbitm...@googlegroups.com
You're right, i've never mentioned this, sorry.
The quorum table was about 70MB, when just booted is about 20MB, but the big difference was preallocated by runtime, unused of about 800MB

Karl Nilsson

unread,
Jan 4, 2021, 12:21:07 PM1/4/21
to rabbitmq-users
the runtime will adjust the pre-allocation based on previous memory use - I'd still try lowering the WAL limit as it may bring peak memory usage down and with it the pre-allocation amount. Possibly.

Marco Lettieri

unread,
Jan 8, 2021, 3:24:01 AM1/8/21
to rabbitm...@googlegroups.com
Hello,
i've done as you suggested but the memory quorum queue tables increase anyway and also preallocated by runtime, unused
Schermata 2021-01-08 alle 09.20.06.png
Schermata 2021-01-08 alle 09.20.56.png

Something is still not clear to me: the durable queue are automatically quorum? I've created for sample a quorum queue and the feature section make it evident, but in normal durable queue is not quorum.
Schermata 2021-01-08 alle 09.15.56.pngSchermata 2021-01-08 alle 09.15.11.png

So if the quorum tables is connected to quorum queues, but i've only some durable, how this table increase memory?

This are part of my queues, and memory used/persistent is really low

Schermata 2021-01-08 alle 09.22.59.png

Karl Nilsson

unread,
Jan 8, 2021, 4:07:30 AM1/8/21
to rabbitmq-users
Quorum Queues are always durable but you can also create durable classic queues, in fact, this is the default. As I've explained before the quorum tables memory use will increase until the WAL is full then it will drop down. What max WAL size did you configure? Do you use MQTT?

There are a lot of information in the quorum queue manual page: https://www.rabbitmq.com/quorum-queues.html

Marco Lettieri

unread,
Jan 8, 2021, 4:27:23 AM1/8/21
to rabbitm...@googlegroups.com
I've setted 256M wal max size, yes i use mqtt plugin

Karl Nilsson

unread,
Jan 8, 2021, 9:42:12 AM1/8/21
to rabbitmq-users
ok I see - the MQTT plugin also uses Raft which currently means some memory used by the plugin shows up as "quorum tables" - see https://www.rabbitmq.com/mqtt.html#consensus

Marco Lettieri

unread,
Jan 8, 2021, 9:54:02 AM1/8/21
to rabbitm...@googlegroups.com
yes, i've read that and i've setted in config
raft.wal_max_size_bytes = 67108864

still not explain why quorum and unused increase without limit

Marco Lettieri

unread,
Jan 11, 2021, 3:11:48 AM1/11/21
to rabbitm...@googlegroups.com
Now is 4 days uptime and is 45MB quorum table, what will happen on 67MB (wal max size)?

Karl Nilsson

unread,
Jan 11, 2021, 9:30:48 AM1/11/21
to rabbitmq-users
When the WAL file size reaches 67MB it will flush all in memory log entries ("quorum tables") to disk and remove them from memory. 

One thing to note is that the memory use and the WAL file use are only loosely correlated. If you have many small log entries it may use more memory than on disk due to varying per-disk overhead and how the erlang runtime manages memory.

Marco Lettieri

unread,
Jan 11, 2021, 11:12:50 AM1/11/21
to rabbitm...@googlegroups.com
so what is the best way to have many mqtt connections and don't face up this problem?
When the wal is reached the quorum table are removed from memory but connections and queues still alive, right?
I don't understand why technically the mqtt queues or the mqtt plugin generate this quorum increasing memory usage

Karl Nilsson

unread,
Jan 11, 2021, 11:38:56 AM1/11/21
to rabbitmq-users
It is explained in the documentation link I sent you a few messages ago: https://www.rabbitmq.com/mqtt.html#consensus

Marco Lettieri

unread,
Jan 18, 2021, 3:23:16 AM1/18/21
to rabbitm...@googlegroups.com
Hello Karl,
we're about at 10 days uptime and i see quorum table increasing anyway, also with raft.wal_max_size_bytes = 67108864

Schermata 2021-01-18 alle 09.17.36.png
Schermata 2021-01-18 alle 09.17.26.png

Marco Lettieri

unread,
Apr 20, 2021, 9:08:50 AM4/20/21
to rabbitm...@googlegroups.com
After changed the parameter wal i still see memory increasing (slower of course).
Uptime 89 days, 1GB memory used. I know if i reboot it will return to around 400MB
Schermata 2021-04-20 alle 15.05.27.png
Schermata 2021-04-20 alle 15.05.42.png
Reply all
Reply to author
Forward
0 new messages