Limits

Every MQTT limit in the [mqtt] table, how it is announced in CONNACK, and what clients see when they exceed it.

All limits live in the [mqtt] table of orbitmq.toml, and each can be overridden with ORBITMQ_ plus the upper-case key (for example ORBITMQ_RECEIVE_MAXIMUM=100). Types and defaults are in the configuration reference.

Defaults follow the specifications. A default broker behaves exactly as MQTT describes when a CONNACK property is absent. When you change a limit that MQTT 5.0 defines a CONNACK property for, the broker announces the new value in CONNACK so that well-behaved MQTT 5.0 clients never exceed it. MQTT 3.1 and 3.1.1 have no such properties, so those clients only find out by being refused or disconnected.

orbitmq.toml
[mqtt]
max_packet_size = 1048576   # 1 MiB
receive_maximum = 100
maximum_qos = 1
max_connections = 100000

Limits announced in CONNACK

These apply to MQTT 5.0 clients as CONNACK properties, and are enforced for every protocol version.

KeyCONNACK property (5.0)Announced whenExceeded by a client: MQTT 5.0Exceeded: MQTT 3.x
max_packet_sizeMaximum Packet Sizebelow 268435460DISCONNECT 0x95 Packet Too LargeConnection closed
receive_maximumReceive Maximumbelow 65535DISCONNECT 0x93 Receive Maximum ExceededConnection closed
topic_alias_maximumTopic Alias Maximumabove 0 (so the default 32 is always announced)Alias 0 or above the maximum: DISCONNECT 0x94 Topic Alias InvalidNot applicable
maximum_qosMaximum QoS0 or 1PUBLISH above it: DISCONNECT 0x9B QoS Not Supported. Will above it: CONNACK 0x9B. Subscriptions are granted at most this QoSPUBLISH above it closes the connection; subscriptions are granted at most this QoS
retain_availableRetain Available = 0falseRetained PUBLISH: DISCONNECT 0x9A Retain Not Supported. Retained will: CONNACK 0x9ARetained PUBLISH closes the connection
wildcard_subscriptionsWildcard Subscription Available = 0falseSUBACK 0xA2 Wildcard Subscriptions Not SupportedSUBACK failure (0x80)
subscription_identifiersSubscription Identifier Available = 0falseSUBSCRIBE with an identifier: DISCONNECT 0xA1Not applicable
shared_subscriptionsShared Subscription Available = 0falseSUBACK 0x9E Shared Subscriptions Not SupportedApplies only with shared_subscriptions_v3
server_keep_aliveServer Keep Aliveabove 0The announced value replaces the client's keep aliveNot applied; 3.x clients keep their own
max_session_expirySession Expiry Intervalthe granted value is lower than the requested oneThe session expires after the granted intervalPersistent sessions (clean session 0) expire after this

Connection limits

KeyEffectMQTT 5.0 CONNACKMQTT 3.x CONNACK
max_connectionsMost open connections on the node. 0 = unlimited.0x89 Server Busy3, server unavailable
[[listener]] max_connectionsThe same, per listener.0x89 Server Busy3, server unavailable
max_client_id_lenLongest client identifier, in bytes.0x85 Client Identifier Not Valid2, identifier rejected
[auth] verify_queuePassword-file hash checks waiting per core (default 1024; verify_concurrency run at once). See Hashing limits.0x89 Server Busy3, server unavailable
allow_empty_client_idWhether a zero-length client identifier is accepted. When accepted, the broker assigns one and returns it to 5.0 clients as Assigned Client Identifier. MQTT 3.1.1 also requires clean session 1; MQTT 3.1 never allows it.0x85 when refused2, identifier rejected

Refusals because of a connection limit are counted in orbitmq_connections_refused_total{reason="max_connections"}. The time allowed between accepting a connection and receiving CONNECT is the top-level connect_timeout_secs.

Keep alive

The server closes a connection when it has received nothing from the client for one and a half times the Keep Alive interval (the client's value, or server_keep_alive for MQTT 5.0 clients when it is set). A Keep Alive of 0 turns the check off. Any data from the client, not only PINGREQ, restarts the interval.

Each core checks these deadlines, and the CONNECT timeout, with one timer wheel of 10 ms slots instead of a timer per connection. A connection is therefore never closed before one and a half times its Keep Alive, but the close can come up to about 10 ms after that point.

Delivery limits

These shape how the broker sends messages to slow or offline clients. They are not announced, because the MQTT specifications define no property for them.

A slow subscriber never slows down publishers or other subscribers. When its session queue is full, further QoS 1 and QoS 2 messages for that subscriber are dropped and counted, and the publisher's acknowledgement is not affected. How queues are bounded is described in Session queues below.

KeyEffectMetric when it drops messages
max_inflightMost unacknowledged QoS 1 and QoS 2 messages sent to one client. The client's own Receive Maximum is honoured too; the smaller value wins. Further messages wait in the session queue.
max_queued_messagesMessages queued per session while the in-flight window is full or the client is offline. Further QoS 1 and QoS 2 messages are dropped.orbitmq_dropped_messages_total{reason="queue_full"}
max_queued_bytesBytes queued per session (16 MiB by default). Further QoS 1 and QoS 2 messages are dropped. 0 = unlimited.{reason="queue_full"}
max_queued_memory, max_queued_memory_percentNode-wide memory budget (25% of the memory limit by default): queued, in-flight and retained messages, read and outbound buffers. Above it, the oldest messages of the longest queues are dropped first. See Node-wide budget.{reason="memory_limit"}
max_buffered_bytesBytes buffered for one connection. Beyond it, QoS 0 deliveries are dropped and QoS 1 and QoS 2 deliveries wait in the session queue.{reason="qos0_queue_full"}
queue_qos0_offlineWhether QoS 0 messages are queued for offline persistent sessions (off by default).{reason="qos0_queue_full"}
max_message_expiryLongest lifetime of any message, in seconds. Messages without a Message Expiry Interval, or with a longer one, expire after this; the remaining interval is forwarded to MQTT 5.0 subscribers. 0 = unlimited.{reason="expired"}
outbound_topic_aliasesWhether the broker assigns Topic Aliases on PUBLISH packets it sends to 5.0 clients that declared a Topic Alias Maximum.

Messages larger than the Maximum Packet Size a client declared are not sent to it and are counted as {reason="too_large"}, as MQTT 5.0 requires.

Session queues

A session queues QoS 1 and QoS 2 messages while its in-flight window is full or its client is offline. Four keys bound those queues. None of them is announced to clients, and none of them ever slows down a publisher: messages over a limit are dropped and counted, and the publisher is acknowledged as usual.

LimitScopeDefaultEnvironment variable
max_queued_messagesper session10000 messagesORBITMQ_MAX_QUEUED_MESSAGES
max_queued_bytesper session16777216 (16 MiB), 0 = unlimitedORBITMQ_MAX_QUEUED_BYTES
max_queued_memory_percentper node25 (% of the memory limit), 0 = no node budgetORBITMQ_MAX_QUEUED_MEMORY_PERCENT
max_queued_memoryper node0 (use the percentage)ORBITMQ_MAX_QUEUED_MEMORY

Per-session caps. A session's queue holds at most max_queued_messages messages and max_queued_bytes bytes, whichever is reached first. Each queued message is charged its topic, payload and forwarded properties plus a fixed 320 bytes for the broker's own bookkeeping, so the byte cap only binds for larger messages: 10 000 queued 64-byte messages use about 3.4 MB, while about 12 000 queued 1 KiB messages reach 16 MiB. A message that would exceed either cap is dropped for that subscriber and counted as orbitmq_dropped_messages_total{reason="queue_full"}.

Node-wide budget. Many clients together could still hold a lot of memory, so the node also has a memory budget. By default it is 25% of the memory limit: the cgroup limit when the broker runs in a container that has one, otherwise the machine's physical memory. Where neither can be determined, the broker logs a warning and assumes 4 GiB, so the default budget there is 1 GiB. Set max_queued_memory to a number of bytes to use a fixed budget instead (it takes precedence over the percentage), or set max_queued_memory_percent = 0 to turn the budget off. The percentage must be at most 100.

CountedHow
Queued messagesTopic, payload and forwarded properties plus 320 bytes each.
In-flight messagesThe same, until acknowledged (for QoS 2, until PUBREC).
Outbound buffersEncoded bytes waiting for the socket, and writes of 4 KiB or more under way. A QoS 1 or 2 message being sent is charged once.
Read buffersThe buffer holding a packet that has not fully arrived.
Retained messagesTopic, payload and properties.

Subscriptions, session state, TLS and WebSocket state and the memory of the sockets themselves are not counted, so leave room for them. A message delivered to several subscribers shares its payload but is charged to each of them, so the budget errs on the safe side for large messages with many subscribers.

The budget is enforced per core, without coordination between cores: each core gets an equal share (the budget divided by the number of cores). Because sessions are spread over the cores by client identifier, the shares fill evenly in practice, but a core can act while another still has room. A core over its share does the following, in this order:

  1. It drops the oldest messages of its longest queues, bringing the longest queue down to the next longest, until it is back at seven eighths of its share. Short queues of subscribers that keep up are left intact. These drops are counted as orbitmq_dropped_messages_total{reason="memory_limit"}. Publishers are not slowed down.
  2. If that is not enough, sessions take one message at a time in flight, whatever Receive Maximum allows, until the core is back under its share. New messages wait in the queues, which step 1 can shed. A message already sent is never dropped: it stays until it is acknowledged, and is sent again when a persistent session reconnects.
  3. If buffers themselves hold more than a quarter of the core's share, it closes the connections holding the most: those sending a packet that does not fit (a large partial packet, also before CONNECT) and subscribers that have stopped reading. MQTT 5.0 clients that are still reading get DISCONNECT with reason code 0x97 (Quota exceeded); MQTT 3.x connections are simply closed. The Will Message is published as for any abnormal close, and a persistent session stays. A subscriber that keeps up is not closed, whatever it holds. These closes are counted as orbitmq_memory_budget_closes_total.

Retained messages are never dropped to make room: they only leave less of the budget to everything else, so give them their own limits (max_retained_messages, max_retained_bytes) if they can grow.

Defaults and the full-load profile. The defaults are conservative. Measured on development hardware, 10 000 queued messages absorb a 1-second subscriber stall at 10 000 messages per second, or a 5-second stall at 1 000 messages per second, without loss. For high-throughput deployments where subscribers may stall for longer, the measured full-load profile is:

orbitmq.toml
[mqtt]
max_queued_messages = 100000      # no loss for stalls up to 5 s at 10k msg/s, or 1 s at 50k msg/s
max_queued_bytes = 67108864       # 64 MiB per session
max_queued_memory_percent = 50

Raising the limits. If queue_full drops grow for subscribers that only stall briefly, raise max_queued_messages or max_queued_bytes (or set the byte cap to 0). If memory_limit drops grow, give the broker more memory (a higher container limit raises the default budget with it), raise max_queued_memory_percent, or set an explicit max_queued_memory. orbitmq_memory_used_bytes{kind} shows what fills the budget.

orbitmq.toml
[mqtt]
max_queued_messages = 500000
max_queued_bytes = 268435456      # 256 MiB per session
max_queued_memory = 8589934592    # 8 GiB for the whole node, instead of a percentage
ORBITMQ_MAX_QUEUED_BYTES=0 ORBITMQ_MAX_QUEUED_MEMORY_PERCENT=70 orbitmq

A subscriber that persistently reads slower than messages are published to it loses messages with any finite queue; the limits only decide when, and that the rest of the node is unaffected.

Retained message limits

KeyEffect
max_retained_messagesRetained messages per core shard. 0 = unlimited.
max_retained_bytesBytes of retained messages per core shard. 0 = unlimited.

Retained messages are spread over the cores by topic, so the node-wide capacity is roughly the per-shard limit times the number of cores. A retained message that would exceed a limit is not stored (the broker logs a warning), but it is still delivered to current subscribers. Replacing the message of an existing retained topic does not count against max_retained_messages.

The defaults follow the specifications, which set few limits. On a broker that clients you do not control can reach, tighten them. These are starting points to adjust to your traffic, not requirements:

KeyDefaultRecommendedWhy
allow_anonymous ([auth])anonymous unless an authentication source is setfalseEverything below is easier to abuse without an identity.
max_connections0 (unlimited)what your memory holds, with room to spareEach connection and session holds memory the budget does not count.
max_packet_sizeprotocol maximum (256 MiB)1048576 (1 MiB), or your largest messageBounds what one packet can hold in a read buffer.
max_session_expirynever expires86400 (one day) or lessSessions without a client keep their subscriptions and queues; this also caps MQTT 3.x persistent sessions, which otherwise never expire.
max_message_expiry0 (unlimited)86400Bounds how long a queued message can wait.
receive_maximum65535100 to 1000Unacknowledged messages one client may publish.
max_inflight65535100 to 1000Unacknowledged messages held for one client.
max_queued_bytes16 MiB1048576 (1 MiB) for small devicesWith max_queued_messages, bounds one session's queue.
max_retained_messages, max_retained_bytes0 (unlimited)set both, per core, for example 100000 and 268435456 (256 MiB)Retained messages are never dropped to make room in the budget.

Subscriptions per client and topic levels have no configuration key: restrict the topics clients may use with authorization rules. Message rates have no limit either.

Other switches

KeyEffect
shared_subscriptions_v3Treat $share/{group}/{filter} as a shared subscription for MQTT 3.1 and 3.1.1 clients too. Off by default, where it is an ordinary topic filter as those specifications define.

On this page