Limits and Timeouts
Introduction
This guide provides an overview of the configurable limits and timeouts provided by RabbitMQ, followed by the hardcoded limits that cannot be changed.
This guide intentionally leaves out some advanced configurable limits.
In this guide, we define a configurable limit as a setting, configured via rabbitmq.conf, virtual host metadata,
a policy, an operator policy, or any other means, that controls how many connections, channels, queues, streams,
or other application-controlled resources would be allowed in a cluster or on a specific node.
Many of these limits are covered in more detail in dedicated guides.
Why Use Configurable Limits
Modern messaging and streaming protocols, such as those supported by RabbitMQ, give application developers the freedom to define their topology resources (such as queues and streams, exchanges, bindings and so on).
Some of these resources can be unintentionally leaked by applications. For example, an application can leave a connection (or channel, session) open, not clean up queues or streams that are no longer needed, and so on.
Configurable limits are a protection mechanism that allows cluster operators to prevent such applications from using enough resources to affect other applications or cluster stability.
Such guardrails are particularly important when RabbitMQ clusters are offered as a service.
Available Limits
Per Virtual Host Limits
Per virtual host limits, as the name suggests, apply to a specific virtual host:
- The maximum number of concurrent client connections in the virtual host
- The maximum number of queues and streams that can be declared in a virtual host
Per User Limits
Per user limits apply to user accounts (usernames):
- The maximum number of concurrent client connections that authenticate as that user
- The maximum number of concurrent channels open across all of the user's connections
Per Connection Limits
Per connection limits apply to individual client connections.
rabbitmq.conf Setting | Type | Description | Default |
|---|---|---|---|
max_channels_per_connection | integer | Maximum number of AMQP 0-9-1 channels a client can open on a single connection. Protects against applications leaking channels. Channel number 0 is reserved for internal use. While the default is 2047, values between 16 and 128 are recommended for most use cases. | 2047 |
session_max_per_connection | integer | Maximum number of AMQP 1.0 sessions per connection | 64 |
link_max_per_session | integer | Maximum number of AMQP 1.0 links per session | 256 |
handshake_timeout | integer (milliseconds) | Maximum time allowed for AMQP 0-9-1 and AMQP 1.0 handshake to complete | 10000 (10 seconds) |
ssl_handshake_timeout | integer (milliseconds) | Maximum time allowed for TLS handshake to complete | 5000 (5 seconds) |
heartbeat | integer (seconds) | Heartbeat timeout value suggested by the server during connection negotiation | 60 |
frame_max | integer (bytes) | Maximum AMQP 1.0, AMQP 0-9-1 and RabbitMQ Stream Protocol frame size. Should not be changed; rely on server and client library defaults. | 131072 (128 KiB) |
initial_frame_max | integer (bytes) | Maximum frame size before connection tuning. Should not be changed; rely on server and client library defaults. | 8192 |
Some protocols supported by RabbitMQ have their own specific limits.
MQTT
MQTT connections have a session expiry interval limit:
rabbitmq.conf Setting | Type | Description | Default |
|---|---|---|---|
mqtt.max_session_expiry_interval_seconds | integer (seconds) | Maximum session expiry interval that MQTT clients can request | 86400 (1 day) |
Per Channel Limits
consumer_max_per_channel controls the maximum number of consumers that can be registered on a single channel.
This setting protects against applications leaking consumers.
The default is unlimited. To set a limit, configure it in rabbitmq.conf:
consumer_max_per_channel = 10
Per Cluster Limits
The following settings are defined in rabbitmq.conf but effectively
apply to the entire cluster, because the entities they limit are replicated across all nodes.
rabbitmq.conf Setting | Type | Description | Default |
|---|---|---|---|
vhost_max | integer | Maximum number of virtual hosts that can be created in the cluster | unlimited |
cluster_exchange_limit | integer | Maximum number of exchanges that can be declared in the cluster | unlimited |
cluster_queue_limit | integer | Maximum number of queues that can be declared in the cluster | unlimited |
As these settings are cluster-wide but configured individually for each node using its rabbitmq.conf configuration file,
they must be set to the same value across all cluster nodes.
Per Node Limits
Per node limits apply to individual cluster nodes. They affect all virtual hosts and users.
Due to their coarse-grained nature, these limits are typically used as guardrails in environments where RabbitMQ clusters are offered as a service and cluster operators have no understanding or control over what the deployed applications do.
See also: open file handles limit.
rabbitmq.conf Setting | Type | Description | Default |
|---|---|---|---|
consumer_timeout | positive integer (milliseconds) | Defines how long RabbitMQ will wait for delivery acknowledgements from consumers | 1800000 (30 minutes) |
max_connections | integer | Maximum number of concurrent AMQP 1.0 and AMQP 0-9-1 connections a node will accept | unlimited |
mqtt.max_connections | integer | Maximum number of concurrent MQTT connections a node will accept | unlimited |
stomp.max_connections | integer | Maximum number of concurrent STOMP connections a node will accept | unlimited |
channel_max_per_node | integer | Maximum number of channels across all connections on a node | unlimited |
ranch_connection_max | integer | Maximum number of concurrent TCP connections a node will accept; includes HTTP API connections | unlimited |
stream.max_connections | integer | Maximum number of concurrent RabbitMQ Stream Protocol client connections a node will accept | unlimited |
max_message_size | integer (bytes) | Maximum message size that messaging and streaming clients can publish. Messages larger than this will be rejected. Maximum allowed value is 512 MiB. | 16777216 (16 MiB) |
management.http.max_body_size | integer (bytes) | Maximum HTTP API request body size | 20971520 (20 MiB) |
connection_max and channel_max remain supported aliases for max_connections
and max_channels_per_connection, respectively. Prefer the newer names.
Per Queue Limits
Individual queues can have limits configured via policies:
- Queue length limit: limits ready messages or their total size. Quorum queues also count delayed messages and messages pending at-least-once dead lettering. When the limit is reached, messages are either dropped from the head or new publishes are rejected.
- Message TTL: messages in a queue expire after a specified time period.
- Queue TTL: queues are automatically deleted after a period of inactivity.
- Delivery limit (quorum queues): maximum number of delivery attempts before a message is dropped or dead-lettered.
Default is 20 in RabbitMQ 4.0+, was unlimited in 3.x. Configured via the
delivery-limitpolicy key or queue argument. - Priority levels (priority queues):
x-max-priorityqueue argument defines the maximum priority level (1-255). Values between 1 and 5 are recommended for optimal performance.
Per Stream Limits
Streams have retention settings that control data expiration:
max-age: maximum age of messages in the stream (e.g.,7Dfor 7 days)max-length-bytes: maximum total size of the stream in bytes
When retention limits are reached, the oldest segments are discarded. These can be configured via policies or as optional stream arguments at stream declaration time.
Consult the streams guide to learn more.
Hardcoded Limits
The limits below cannot be changed. Most of them bound the resources that client-provided input can use. Unless noted otherwise, an operation that exceeds a limit fails with an error.
Most limits that come from a protocol specification are not listed.
Messages, Queues, Streams and Bindings
| Limit | Value |
|---|---|
Maximum value of max_message_size | 512 MiB |
| Size of binding arguments, encoded as an AMQP 0-9-1 table | 16 KiB |
# wildcards in a topic exchange binding key | 2 |
Entries in each of the AMQP 0-9-1 CC and BCC headers and in the AMQP 1.0 x-cc message annotation | 64 |
x-message-ttl and x-expires queue arguments, and the AMQP 0-9-1 expiration message property | 10 years (315,360,000,000 ms) |
x-max-priority of classic queues | 255 |
| Quorum queue message priorities. Higher values are treated as 31 | 0 to 31 |
x-name-prefix of server-named queues | 64 bytes |
| Direct reply-to destinations per published message. Further destinations are ignored | 2 |
Stream segment size (x-stream-max-segment-size-bytes) | 4096 bytes to 3,000,000,000 bytes |
Stream Bloom filter size (x-stream-filter-size-bytes) | 16 to 255 bytes |
Users, Permissions and Policies
| Limit | Value |
|---|---|
| Tags per user | 32 |
| Length of a regular expression in a policy pattern, a permission or a topic permission | 4096 bytes |
| Match steps per regular expression evaluation. A match that exceeds the limit counts as no match: a permission check fails and a policy does not apply | 50,000 |
The match step limit also applies to LDAP match queries, federation upstream patterns, the JMS topic exchange and the HTTP API name filter.
AMQP 0-9-1
| Limit | Value |
|---|---|
| Queue names, exchange names, routing keys and consumer tags (AMQP 0-9-1 short strings) | 255 bytes |
Minimum frame_max that a client can negotiate | 8192 bytes |
| Replies that a channel has queued for a client that does not read from its socket. The connection is closed when the limit is reached | 4000 replies, or the greater of 32 MiB and twice max_message_size |
AMQP 1.0
| Limit | Value |
|---|---|
| Sections per message | 10,000 |
| Encoded size of each section before the message body (header, delivery annotations, message annotations, properties, application properties) | 128 KiB |
| Encoded size of an array descriptor | 64 bytes |
Frame size before the open frame has been processed, including SASL frames | 8192 bytes |
Minimum idle-time-out that a client can request | 1 second |
| Fields in a property filter expression | 16 |
| Length of an SQL filter expression | 4096 characters |
| Tokens in an SQL filter expression | 200 |
Length of a value matched by a LIKE pattern that contains _ or more than one %. Longer values do not match | 4096 bytes |
Deferral tokens per flow frame | 256 |
| Size of a deferral token | 256 bytes |
Message annotations that a modified outcome can add to a quorum queue message. Further annotations are ignored | 32 |
| Requests in flight per AMQP 1.0 management link pair | 8 |
A filter expression that exceeds a limit is not applied, and it is left out of the attach frame that RabbitMQ sends in response.
MQTT
| Limit | Value |
|---|---|
| Message Expiry Interval. Larger values are lowered to the limit | 10 years (315,360,000 seconds) |
| Maximum QoS | 1 |
STOMP
| Limit | Value |
|---|---|
| Length of a frame command | 32 bytes |
| Open transactions per connection | 16 |
SEND, ACK and NACK frames per transaction | 1024 |
| Message body bytes across all open transactions of a connection. The connection is closed when the limit is exceeded | 128 MiB |
priority header. Values outside the range are clamped | 0 to 255 |
RabbitMQ Stream Protocol
| Limit | Value |
|---|---|
| Publishers per connection | 256 |
| Subscriptions per connection | 256 |
| Length of a publisher reference, a consumer name and an offset tracking reference | 255 bytes |
HTTP API
| Limit | Value |
|---|---|
Page size (page_size) | 500 |
Samples per series (the *_age parameter divided by the *_incr parameter) for endpoints that return a single object | 500 |
| Samples per series for endpoints that return a list of objects | 60 |
Length of a regular expression in the name filter (use_regex=true) | 1024 bytes |
| Request body size when creating a binding | 5000 bytes |
| Memory used to decode a JSON request body, except for definition imports | about 64 MB |
Prometheus
| Limit | Value |
|---|---|
Length of the queue query parameter | 2000 bytes |
Match steps of the queue regular expression per queue. Queues that exceed the limit are left out of the response | 2000 |
OAuth 2
| Limit | Value |
|---|---|
| Scopes per token | 2048 |
| Length of a regular expression scope pattern | 2048 bytes |
| Match steps per regular expression scope pattern. A match that exceeds the limit counts as no match | 10,000 |
Shovels and Federation
| Limit | Value |
|---|---|
| URI length | 64 KiB |
connection_timeout URI query parameter | 180 seconds |
| Size of TLS certificate and key files referenced in URIs | 4 MiB |
Federation upstream max-hops | 32767 |
Minimum value of the src-delete-after-duration shovel setting | 15 seconds |
Exchange Type Plugins
| Limit | Value |
|---|---|
| Nesting depth of a JMS topic exchange selector | 16 |
| Digits in a numeric literal of a JMS topic exchange selector | 100 |
Length of a JMS topic exchange LIKE pattern after conversion to a regular expression | 4096 bytes |
| Consistent hashing exchange binding weight | 10,000 |
shards-per-node policy key of the sharding plugin | 4096 |