Go to file
David Ansari a934c1da32 PoC: Decrease per message memory usage in QQs
The idea is to use a binary instead of lists to to hold messages
in a quorum queue's incoming queue.

Enqueue = appending to a binary
Dequeue = matching the front of a binary

Per message memory usage prior to this commit:
```
erts_debug:size([[1|2]]).
4
erts_debug:size([[1|2], [3|4]]).
8
```
4 words * 8 bytes (on a 64 bit machine) = 32 bytes

Per message memory usage after this commit:
7 bytes to encode the RaIdx + 4 bytes to encode the message size = 11 bytes

The message bytes encoding can be further optimised and be
below 3 bytes most of the time.
Hence, let's say 10 bytes per message.

Let's assume we have a 3 node cluster with 500 quorum queues and
200,000 messages each per queue. That's 100 million messages across
all queues.

Prior to this commit this would require a total of 9.6 GB of memory:
100,000,000 msgs * 32 bytes * 3 nodes = 9.6 GB

After this commit this requires only a total of only 3 GB of memory:
100,000,000 msgs * 10 bytes * 3 nodes = 3 GB of memory

If there is a message TTL policy set for these queues the savings will
be even more significant because prior to this commit the per message
memory overhead is 6 words * 8 bytes = 48 bytes:
```
erts_debug:size([[1|[2|5000]]]).
6
erts_debug:size([[1|[2|5000]], [3|[4|5000]]]).
12
```

Prior to this commit this would require a total of 14.4 GB of memory:
100,000,000 msgs * 48 bytes * 3 nodes = 14.4 GB

If we assume addional 6 bytes to encode the expiration timestamp in milliseconds,
with a binary encoding, this would require a total of only 4.8 GB of memory:
100,000,000 msgs * 16 bytes * 3 nodes = 4.8 GB

The problem with the binary approach is that appending to a binary at a
rate of 100,000 msgs/s is catastrophically slow:
```
java -jar target/perf-test.jar -qq -u qq1 -x 1 -y 0 -C 1000000
```
* sends at 90766 msg/s pior to this commit
* sends at 3435 msg/s after this commit
After this commit, >80% of CPU time is spent in function
`__memmove_evex_unaligned_erms` copying binary data around.
Appending frequently to the binary becomes even slower as the binary
gets longer.

The only practical solution would be a hybrid approach:
* lists are used by default
* lists will always be used for enqueueing messages (i.e. prepending to the list)
* a binary will be created whenever many messages, e.g. 100,000 new messages got
  accumulated. Such a binary creation will be relatively fast, as
  explained in https://www.erlang.org/doc/system/binaryhandling.html :
  "Appending data to a binary as in the example is efficient because it
  is specially optimized by the runtime system to avoid copying the Acc
  binary every time."
* Once the binary got created, pattern matching at the front and therefore
  dequeueing messages will be fast.
* The binaries themselves will be stored in lists (a list with 10
  binaries means ~1 million messages in total in our example).

It's questionable though whether such an approach is worth the introduced complexities
given that queues are meant to be kept short anyways.
2025-06-15 11:13:22 +00:00
.github ci: nightly OCI project version without leading 'v' 2025-06-12 10:36:27 +01:00
deps PoC: Decrease per message memory usage in QQs 2025-06-15 11:13:22 +00:00
doc Add files to specify license info 2020-08-18 12:42:43 -07:00
mk Use Erlang.mk's native Elixir support for CLI 2025-03-18 10:02:49 +01:00
packaging Use Erlang.mk's native Elixir support for CLI 2025-03-18 10:02:49 +01:00
release-notes Correct a 4.1.1 release notes typo 2025-06-05 16:46:41 +04:00
scripts Remove Bazel files 2025-03-13 13:42:34 +00:00
selenium Delete mqtt qos0 when connection closes 2025-06-04 10:49:19 +02:00
.dockerignore dockerignore deps 2021-03-18 15:04:39 +00:00
.elp.toml Disable eqwalizer 2025-06-07 14:34:14 +02:00
.git-blame-ignore-revs Add #13008 to .git-blame-ignore-revs 2025-01-02 12:08:04 -05:00
.gitignore Split rabbitmq_federation: rabbitmq_queue_federation, rabbitmq_exchange_federation and rabbitmq_federation_common 2025-05-27 07:55:29 +02:00
.mailmap Add .mailmap file 2023-11-03 13:17:30 +01:00
CODE_OF_CONDUCT.md Replace @rabbitmq.com addresses with rabbitmq-core@groups.vmware.com 2023-06-20 15:40:13 +04:00
COMMUNITY_SUPPORT.md Update COMMUNITY_SUPPORT.md 2024-12-03 11:03:34 -05:00
CONTRIBUTING.md Document RABBITMQ_METADATA_STORE in CONTRIBUTING.md 2024-12-19 17:40:34 -05:00
LICENSE Replace @rabbitmq.com addresses with rabbitmq-core@groups.vmware.com 2023-06-20 15:40:13 +04:00
LICENSE-APACHE2 (c) year bumps 2024-01-01 22:02:20 -05:00
LICENSE-MPL-RabbitMQ Revert drop of Exhibit B on MPL 2.0 2020-07-20 17:03:37 +01:00
Makefile Adds rabbit_auth_backend_internal_loopback 2025-04-09 12:53:29 -07:00
PKG_LINUX.md URL Cleanup 2019-03-20 03:22:38 -05:00
PKG_WINDOWS.md Windows doc tweaks 2018-11-08 13:48:46 -08:00
README.md Support AMQP over WebSocket (OSS part) 2025-01-27 17:50:47 +01:00
SERVER_RELEASES.md Update SERVER_RELEASES.md 2025-02-10 14:16:51 -05:00
erlang.mk Update Erlang.mk 2025-03-20 15:24:05 +01:00
erlang_ls.config erlang_ls: Add 'deps/*/' to include dirs 2024-04-12 09:49:34 -04:00
plugins.mk Adds rabbit_auth_backend_internal_loopback 2025-04-09 12:53:29 -07:00
rabbitmq-components.mk Closes #14032 2025-06-05 01:29:07 +04:00
rebar.config Revert "Format MQTT code with `erlfmt`" 2023-01-27 18:25:57 +00:00

README.md

Test

RabbitMQ Server

RabbitMQ is a feature rich, multi-protocol messaging and streaming broker. It supports:

Installation

Tutorials and Documentation

Some key doc guides include

RabbitMQ documentation is also developed on GitHub.

Commercial Features and Support

Getting Help from the Community

Please read the Community Support Eligibility Policy document first.

The recommended community forums are

Contributing

See CONTRIBUTING.md and our development process overview.

Questions about contributing, internals and so on are very welcome in GitHub Discussions or community Discord server in the core-and-plugin-dev channel.

Licensing

RabbitMQ server is licensed under the MPL 2.0.

Community Support Eligibility Policy document explains the open source RabbitMQ support policy adopted by the RabbitMQ Core Team.

Building From Source and Packaging

(c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.