RabbitMQ Queue Memory & Throughput Sizer

RabbitMQ Queue Memory & Throughput Sizer

Interactive RabbitMQ Queue Memory & Throughput Calculator with real-time client-side analysis and visualization.

Presets label

Title cluster config

1Unit nodes15
1Unit replicas7

Title message storage

Lbl backlog depth150,000 Unit msgs
Unit msgs
Unit bytes
Unit bytes

Title traffic consumers

Lbl publish rate2,500
Lbl consume rate2,200
Unit ms

Title node resources

Lbl node ram16 Unit gb
Lbl high watermark40%
Lbl paging ratio50%
Lbl active connections100 Unit conns

Title waterline

Lbl status safe
Lbl zero mbLbl paging marker: 3,277 Unit mb (20%)Lbl alarm marker: 6,554 Unit mb (40%)Lbl total node marker: 16,384 Unit mb
Lbl total leader ram630.8 Unit mb
Lbl watermark util9.6%
Lbl headroom remaining5,922.8 Unit mb
Lbl cluster total ram1.54 Unit gb

Title svg pipeline

Lbl svg engine
Svg publishers2,500 Unit msg per sec6.26 Unit mb per secSvg socket buffer100 Unit conns15.6 Unit mb Svg beam raft631 Unit mbQUORUM (3 Unit nodes)Lbl disk io: 21.58 Unit mb per secSvg resident ram149,000 Unit msgs447.4 Unit mb Lbl payloads tagSvg disk segments0 Unit msgs0.36 Unit gb Lbl on disk tagSvg consumers20 Unit workersLbl prefetch short: 1,000 Unit msgsLbl net velocity+300 Unit msg per secLbl timeline indicatorLbl alarm in 1h 37m

Title ram breakdown630.8 Unit mb

Lbl resident payload:447.4 Unit mb
Lbl prefetch buffers:2.7 Unit mb
Lbl beam heap:165 Unit mb
Lbl socket buffers:15.6 Unit mb
Primary MetricLbl status safe
Efficiency / Capacity100% Client-Side Privacy
Net Output631 Unit mb (10%)
Technical Reference & Architecture Guide

RabbitMQ Queue Memory & Throughput Sizer Guide

Interactive RabbitMQ Queue Memory & Throughput Calculator with real-time client-side analysis and visualization.

RabbitMQ Queue Memory & Throughput Sizer Guide — Client-Side In-Memory Architecture & Data Flow
RabbitMQ Queue Memory & Throughput Sizer Guide — Client-Side In-Memory Architecture & Data Flow

Key Parameters & Controls

queueArchitectureTypeEnum ('quorum' | 'classic_v2' | 'stream' | 'classic_v1')

Specifies the Erlang BEAM consensus engine and storage subsystem. Quorum queues implement Raft consensus requiring approximately 30-40% additional RAM per in-flight state machine entry (~384B vs ~32B in CQv2). Classic Queue v2 segments messages into 32MB immutable disk slabs, reducing paged index memory by 77% compared to Classic Queue v1 Erlang heap ETS dictionaries.

Default: quorum
averageMessagePayloadBytesInteger (Bytes)

Uncompressed AMQP 0-9-1 message body length in bytes. Payloads <= 64 bytes are allocated directly within the local Erlang process heap and subject to copying garbage collection. Payloads > 64 bytes utilize Erlang's global reference-counted binary allocator (refc binaries), allowing multi-subscriber zero-copy memory sharing across AMQP fanout exchanges.

Default: 4096
consumerQosPrefetchCountInteger (Messages / Consumer)

Configured AMQP basic.qos prefetch limit per consumer channel. Messages pushed under prefetch are pinned in unpageable Erlang RAM until acknowledged. Setting prefetch to 0 (unlimited) causes severe RAM bloat under backlog spikes. The gold benchmark interval for sustained network throughput without memory saturation is 50 to 200.

Default: 100
activeConsumerCountInteger (Active AMQP Channels)

Total concurrent worker channels holding active basic.consume tags. Multiplied directly by consumerQosPrefetchCount and averageMessagePayloadBytes to calculate total unpageable in-flight memory allocation: M_inflight = Consumers * Prefetch * (PayloadBytes + 120B BEAM frame metadata).

Default: 20
targetPublishThroughputRateFloat (Messages / Second)

Sustained ingress throughput. Evaluated against vm_memory_high_watermark (0.40 host RAM default) and disk_free_limit. When ingress rate exceeds consumer acknowledge rate, net backlog velocity governs the time to watermark breach: t_breach = (M_watermark - M_current) / (R_backlog * OverheadPerMsg).

Default: 1500

Pro Tips & Best Practices

Prevent Erlang Refc Binary Memory Leaks with Message Sub-Slicing

AMQP messages larger than 64 bytes reside on Erlang's global reference-counted binary heap (refc binaries). If a consumer or broker plugin extracts a tiny header slice from a 1MB payload, the Erlang BEAM runtime retains the entire 1MB binary allocation in physical RAM until that tiny sub-binary is garbage collected. In high-throughput routing pipelines, force binary copying or string re-encoding to release the underlying refc reference and eliminate phantom memory growth.

Mitigate Raft WAL Fsync Latency in High-Throughput Quorum Queues

Quorum queues flush append-only Raft write-ahead logs to disk using fsync() operations. On cloud block storage with volatile write latency (e.g., AWS EBS gp2 burst exhaustion), IOPS throttling can cap queue throughput at 200 msg/s regardless of available CPU cores. Tune raft.wal_max_batch_size to 4096 and place /var/lib/rabbitmq on high-performance NVMe SSDs delivering >= 10,000 sustained write IOPS to scale past 30,000 msg/s per quorum queue.

Decouple Connection Handshakes from AMQP Channel Multiplexing

Every active TCP connection consumes kernel socket memory (rmem/wmem allocating 64KB-256KB) plus Erlang reader process overhead (~40KB). Multiplexing hundreds of active channels over a single connection causes head-of-line blocking on single-threaded Erlang socket readers. Maintain a balanced pool with 10 to 50 active channels per TCP connection to saturate multi-core BEAM schedulers without exhausting socket file descriptors.

Client-Side Zero-Exfiltration O(1) Memory Modeling Guarantees

All queue sizing and backlog drain projections execute entirely client-side using deterministic O(1) closed-form algebraic equations and in-memory Web Workers. Cluster topology metrics, queue depth statistics, and payload sizing parameters never leave your local browser sandbox or hit external network endpoints, guaranteeing strict confidentiality for enterprise infrastructure audits.

Common Gotchas & Troubleshooting

⚠️Publisher connections blocked indefinitely with AMQP basic.publish freezing without errors

Execute 'rabbitmq-diagnostics memory_breakdown' to verify if vm_memory_high_watermark (default 0.40) is tripped. RabbitMQ implements backpressure by halting reads from publisher TCP sockets, filling the client-side socket buffer and freezing the publisher thread without raising AMQP protocol exceptions. Do not increase the watermark beyond 0.50. Instead, decrease consumer basic.qos prefetch to <= 100 to release unacknowledged messages, horizontally scale consumers, or purge dormant dead-letter queues.

⚠️Erlang BEAM process crashes unexpectedly with 100% RAM usage despite low message backlog

Identify unacknowledged message leakage and atom table exhaustion. Run 'rabbitmqctl list_queues name messages_unacknowledged consumers'. If messages_unacknowledged is high, consumers are dropping acknowledgments, locking messages permanently in RAM. Additionally, inspect custom AMQP routing headers to ensure publishers are not dynamically generating unique string headers converted to Erlang atoms, as the BEAM atom table has a hard limit of 1,048,576 entries and crashes the broker immediately upon exhaustion.

⚠️Quorum Queue memory steadily climbs despite messages being paged to disk

Check the quorum queue sliding window cache setting 'quorum_commands_soft_limit' (default 32,768 messages). Quorum queues keep recently committed messages in memory cache for low-latency consumer delivery. Under deep backlogs with fast publishers and slow consumers, configure 'quorum_commands_soft_limit = 1000' and apply an 'x-max-in-memory-length' policy to enforce aggressive in-memory eviction to disk without violating Raft durability.

Frequently Asked Questions

How to calculate RabbitMQ memory usage per queue?▼

Total queue memory is calculated as: M_total = M_payload + M_metadata + M_inflight + M_socket, where M_payload represents message bodies resident in RAM, M_metadata represents BEAM process index overhead (~32B for Classic Queue v2, ~140B for Classic Queue v1, ~384B for Quorum Queues), M_inflight = Consumers * basic.qos Prefetch * (Payload + Metadata), and M_socket allocates 64KB-256KB per TCP connection. For example, 50 consumers with prefetch set to 100 processing 4KB messages pin 50 * 100 * 4.12KB = 20.6 MB in unpageable in-flight RAM alone.

What is a good vm_memory_high_watermark benchmark for production RabbitMQ?▼

The recommended production benchmark for vm_memory_high_watermark is 0.40 to 0.45 (40% to 45% of total system RAM), reserving the remaining 55% to 60% for operating system page cache, socket buffers, and Erlang BEAM garbage collection compaction sweeps. Setting the watermark above 0.55 creates severe risk of Linux Out-Of-Memory (OOM) killer invocation, because Erlang's copying garbage collector can momentarily double a process's resident heap size during memory compaction before memory alarms can throttle incoming publishes.

How much memory does a Quorum Queue use compared to Classic Queue?▼

For active in-memory messages, Quorum queues require approximately 30% to 40% more memory per message than Classic Queue v2 due to Raft consensus tracking (term, index, and command metadata: ~384B vs ~32B per message). However, Quorum queues store log segments directly on disk and maintain an eviction cache window, completely eliminating the severe Erlang heap fragmentation and cluster-wide synchronization stalls that plague legacy mirrored Classic Queues (HA sync).

What happens when RabbitMQ hits vm_memory_high_watermark?▼

When total Erlang memory usage exceeds vm_memory_high_watermark, RabbitMQ immediately trips a cluster-wide memory alarm, stops reading from producer TCP sockets, and suspends basic.publish processing. Producers block on their local TCP socket write buffers without receiving an AMQP error, while consumers continue processing unblocked. Once resident memory drops below the watermark through message consumption and BEAM garbage collection, RabbitMQ clears the alarm and automatically resumes publisher socket polling.

How does consumer prefetch count (QoS) affect RabbitMQ RAM?▼

The basic.qos prefetch setting defines how many unacknowledged messages RabbitMQ pushes to a consumer before waiting for a basic.ack. Dispatched messages are pinned in Erlang process memory and cannot be paged to disk regardless of memory pressure. If 50 consumers have prefetch set to 1,000 handling 10KB messages, this allocates 50 * 1,000 * 10KB = 500 MB of unpageable in-flight RAM. Restricting prefetch to 50-100 maintains line-rate network saturation while keeping in-flight RAM below 50 MB.

How to calculate RabbitMQ queue backlog drain time?▼

Backlog drain time is calculated using the formula: Drain Time (seconds) = Backlog Message Count / (Total Consumer Drain Rate msg/s - Incoming Publish Rate msg/s). If 20 consumers acknowledge 150 msg/s each (3,000 msg/s aggregate) against an incoming publish rate of 1,000 msg/s, the net drain velocity is 2,000 msg/s. A backlog of 500,000 messages will drain in 500,000 / 2,000 = 250 seconds (4 minutes and 10 seconds). If consumer rate is less than or equal to publish rate, backlog drain time is infinite and indicates an expanding queue.

What is the difference between Classic Queue v1 and v2 memory overhead?▼

Classic Queue v1 (CQv1) stores queue indexes inside Erlang process dictionary structures, retaining 120B to 140B in RAM per message even after payload bodies page out to disk. In contrast, Classic Queue v2 (CQv2) stores messages and indexes in immutable 32MB disk segment files, reducing in-memory overhead for paged messages by over 75% down to approximately 32B per message. In a 10-million message backlog, CQv1 forces ~1.4 GB of resident Erlang heap index memory, while CQv2 requires only ~320 MB.

Related Tools & Utilities

All Tools →