MQTT vs HTTPS benchmarks: what one message really costs

Networking

“MQTT is lighter than HTTP” is the one thing most people know about MQTT. It is true, but by how much, and where? Its 2-byte header is not what goes over the network: every message also pays for IP, TCP and TLS, and those layers are the same for both protocols. This benchmark measures what each protocol costs once all of that is counted, on a fast network and on two slow ones.

Everything below was measured on one machine, in Docker, with both protocols sharing the same TLS settings, the same certificate and the same emulated links. Every message carries its sequence number and a payload derived from it, and every receiver checks every byte: 32,733,670 delivered messages, 0 corrupted, 0 duplicated.

SetupDetails
MQTT brokerMosquitto 2.1.2 (eclipse-mosquitto:2, OpenSSL 3.5), defaults apart from the TLS listener and allow_anonymous true, TLS 1.3 only · a second instance with set_tcp_nodelay true, the only setting changed
HTTPS serverGo 1.24.13 net/http, TLS 1.3, HTTP/1.1 and HTTP/2 on the same port · POST publishes, Server-Sent Events (SSE) push to subscribers, empty poll answers 204
ClientsGo 1.24.13: a minimal MQTT 5 client (CONNECT, PUBLISH at QoS 0/1/2, SUBSCRIBE, PING; one TLS record per packet) and the standard net/http client
TLS1.3 on both, same ECDSA P-256 certificate, key exchange X25519MLKEM768 (Go’s default, accepted by both servers), no session resumption: every new connection does a full handshake
NetworkOne network namespace, IPv4 loopback at a 1,500-byte MTU with segmentation offloads off, so packets have real Ethernet sizes · links emulated with tc netem: LAN (nothing added), 50 ms round trip (25 ms each way), 200 ms round trip with 1 % random loss in each direction
CPUAMD Ryzen AI Max+ 395 · cores 0–7 and their SMT siblings reserved for the benchmark: system services, kernel workqueues and every movable IRQ moved to the other CCD, energy preference performance · servers on core 2 (one active at a time), clients on cores 4–7
MethodEvery cell is a fresh client process, run 10 times · reported value: median of the 10 runs (mean of the two middle ones), with min–max · latency p99: each run’s 99th percentile, median across runs · bytes from the interface counters: IP packets, all headers included, before and after · one warm-up message before every latency, throughput and fan-out cell, so both protocols start on an open, used connection · a wait for a quiet link before every cell

Bytes on the wire for one message

The first question is the simplest: on a connection that is already open, how many bytes cross the network to publish one message? Only the publisher’s connection is measured here: the device sending a reading to a server. Start with the smallest message, a 16-byte sensor reading, and where its bytes go:

How the bytes of one 16-byte message on an open connection divide into IP and TCP headers, TLS framing, the protocol's own bytes and the payload. MQTT QoS 0: 104 B TCP/IP in 2 packets, 22 B TLS, 20 B MQTT, 16 B payload, 162 B in total. HTTPS, HTTP/1.1: 104 B TCP/IP in 2 packets, 44 B TLS, 222 B HTTP headers (text), 16 B payload, 386 B in total. One 16-byte reading on the wire: 162 bytes over MQTT, 386 over HTTP/1.1 Same IP, TCP and TLS underneath; the difference is header text. IP + TCP headers TLS framing the protocol itself your 16 bytes MQTT QoS 0 162 B 104 B IP + TCP (2 packets × 52) + 22 B TLS (1 record) + 20 B MQTT + 16 B payload HTTPS, HTTP/1.1 386 B 104 B IP + TCP (2 packets × 52) + 44 B TLS (2 records) + 222 B HTTP headers (text) + 16 B payload MQTT's 2-byte header is not the saving: both messages carry 126–148 B of IP, TCP and TLS. The gap is 222 B of HTTP header text against 20 B of MQTT framing.
One 16-byte reading on a connection that is already open, as measured on the interface (median of 10 runs × 200 messages), divided by what every packet and every TLS record costs: 52 B of IPv4 + TCP headers per packet, 22 B of TLS 1.3 framing per record. Both protocols pay those two layers; what differs is the protocol's own bytes.
How the bytes of one 16-byte message on an open connection divide into IP and TCP headers, TLS framing, the protocol's own bytes and the payload. MQTT QoS 0: 104 B TCP/IP in 2 packets, 22 B TLS, 20 B MQTT, 16 B payload, 162 B in total. HTTPS, HTTP/1.1: 104 B TCP/IP in 2 packets, 44 B TLS, 222 B HTTP headers (text), 16 B payload, 386 B in total. One 16-byte reading on the wire: 162 bytes over MQTT, 386 over HTTP/1.1 Same IP, TCP and TLS underneath; the difference is header text. IP + TCP headers TLS framing the protocol itself your 16 bytes MQTT QoS 0 162 B 104 B IP + TCP (2 packets × 52) + 22 B TLS (1 record) + 20 B MQTT + 16 B payload HTTPS, HTTP/1.1 386 B 104 B IP + TCP (2 packets × 52) + 44 B TLS (2 records) + 222 B HTTP headers (text) + 16 B payload MQTT's 2-byte header is not the saving: both messages carry 126–148 B of IP, TCP and TLS. The gap is 222 B of HTTP header text against 20 B of MQTT framing.
One 16-byte reading on a connection that is already open, as measured on the interface (median of 10 runs × 200 messages), divided by what every packet and every TLS record costs: 52 B of IPv4 + TCP headers per packet, 22 B of TLS 1.3 framing per record. Both protocols pay those two layers; what differs is the protocol's own bytes.

For a 16-byte reading, MQTT at QoS 0 puts 162 B on the wire and HTTP/1.1 386 B, 2.4× as much. Where MQTT’s bytes go:

That is 162 B in 2 packets to deliver 16 bytes. MQTT’s 2-byte header is real, but the per-message floor is set by TCP, IP and TLS, which HTTPS pays too. What HTTPS adds on top is text: a request line, Host, User-Agent, Content-Type, Content-Length and Accept-Encoding headers on the way up, a status line and a Date header on the way down. HTTP/2 compresses those headers against a table both ends keep for the connection; its frames and flow-control updates take 4 packets per message instead of 2, but fewer bytes: 328 B.

QoS 1 adds a PUBACK, which rides in the packet that would have carried the TCP acknowledgement anyway: 192 B, almost free. QoS 2’s four-packet handshake costs 347 B. The same picture across three payload sizes:

Bytes on the wire per message, publisher connection only, connection already open, IP and TCP headers included. 16-byte payload: MQTT QoS 0 162, MQTT QoS 1 192, MQTT QoS 2 347, HTTPS, HTTP/1.1 386, HTTPS, HTTP/2 328, HTTPS, new connection each 4721. 256-byte payload: MQTT QoS 0 403, MQTT QoS 1 433, MQTT QoS 2 588, HTTPS, HTTP/1.1 627, HTTPS, HTTP/2 576, HTTPS, new connection each 4963. 4096-byte payload: MQTT QoS 0 4373, MQTT QoS 1 4429, MQTT QoS 2 4584, HTTPS, HTTP/1.1 4724, HTTPS, HTTP/2 4701, HTTPS, new connection each 9182. For a 16-byte reading HTTP/1.1 sends 2.4× the bytes of MQTT; at 4 KiB they are within 8 % Connection already open · bytes per message, all headers included · each payload size has its own scale MQTT HTTPS 16-byte payload: a sensor reading MQTT QoS 0 162 B MQTT QoS 1 192 B · 1.2× MQTT QoS 2 347 B · 2.1× HTTP/1.1 386 B · 2.4× HTTP/2 328 B · 2.0× Same message, new HTTPS connection each time: 4,721 B · 29× 256-byte payload: a small JSON document MQTT QoS 0 403 B MQTT QoS 1 433 B · +7 % MQTT QoS 2 588 B · 1.5× HTTP/1.1 627 B · 1.6× HTTP/2 576 B · 1.4× Same message, new HTTPS connection each time: 4,963 B · 12× 4 KiB payload MQTT QoS 0 4,373 B MQTT QoS 1 4,429 B · +1 % MQTT QoS 2 4,584 B · +5 % HTTP/1.1 4,724 B · +8 % HTTP/2 4,701 B · +7 % Same message, new HTTPS connection each time: 9,182 B · 2× The floor is IP, TCP and TLS, which both protocols pay. Opening a new connection per message costs as much as 29 small MQTT messages.
Median of 10 process runs, each sending 200 messages (50 for a new connection each time) and reading the network interface counters before and after. Each payload size has its own scale; the ratio after a bar compares it with MQTT QoS 0 at the same payload.
Bytes on the wire per message, publisher connection only, connection already open, IP and TCP headers included. 16-byte payload: MQTT QoS 0 162, MQTT QoS 1 192, MQTT QoS 2 347, HTTPS, HTTP/1.1 386, HTTPS, HTTP/2 328, HTTPS, new connection each 4721. 256-byte payload: MQTT QoS 0 403, MQTT QoS 1 433, MQTT QoS 2 588, HTTPS, HTTP/1.1 627, HTTPS, HTTP/2 576, HTTPS, new connection each 4963. 4096-byte payload: MQTT QoS 0 4373, MQTT QoS 1 4429, MQTT QoS 2 4584, HTTPS, HTTP/1.1 4724, HTTPS, HTTP/2 4701, HTTPS, new connection each 9182. For a 16-byte reading HTTP/1.1 sends 2.4× the bytes of MQTT; at 4 KiB they are within 8 % Connection already open · bytes per message, all headers included · each payload size has its own scale MQTT HTTPS 16-byte payload MQTT QoS 0 162 B MQTT QoS 1 192 B · 1.2× MQTT QoS 2 347 B · 2.1× HTTP/1.1 386 B · 2.4× HTTP/2 328 B · 2.0× new connection each: 4,721 B · 29× 256-byte payload MQTT QoS 0 403 B MQTT QoS 1 433 B · +7 % MQTT QoS 2 588 B · 1.5× HTTP/1.1 627 B · 1.6× HTTP/2 576 B · 1.4× new connection each: 4,963 B · 12× 4 KiB payload MQTT QoS 0 4,373 B MQTT QoS 1 4,429 B · +1 % MQTT QoS 2 4,584 B · +5 % HTTP/1.1 4,724 B · +8 % HTTP/2 4,701 B · +7 % new connection each: 9,182 B · 2× The floor is IP, TCP and TLS, which both protocols pay. Opening a new connection per message costs as much as 29 small MQTT messages.
Median of 10 process runs, each sending 200 messages (50 for a new connection each time) and reading the network interface counters before and after. Each payload size has its own scale; the ratio after a bar compares it with MQTT QoS 0 at the same payload.

As payloads grow, the fixed costs stop mattering. At 4 KiB, HTTP/1.1 sends 8 % more than MQTT QoS 0. What does not shrink is the cost of not keeping the connection open: an HTTPS request on a fresh connection costs 4,721 B for the same 16-byte reading, 29× MQTT’s, because every request pays for TCP’s handshake, a full TLS handshake with the certificate, and the teardown.

The gap that matters is therefore not MQTT against HTTP; it is a kept-open connection against a new one per message. A device that wakes up, connects, posts one reading and disconnects spends almost all of its bytes on the handshake, whichever protocol it speaks.

Opening a connection

That makes the connection itself worth measuring: from nothing to the first message acknowledged, with a full TLS 1.3 handshake.

Time from opening a connection to the first message acknowledged, per link. LAN, no added delay: MQTT, TCP_NODELAY on 1.89 ms, MQTT, broker defaults 42.9 ms, HTTPS, HTTP/1.1 1.70 ms, HTTPS, HTTP/2 1.83 ms. 50 ms round trip: MQTT, TCP_NODELAY on 204 ms, MQTT, broker defaults 294 ms, HTTPS, HTTP/1.1 153 ms, HTTPS, HTTP/2 153 ms. 200 ms round trip, 1 % loss: MQTT, TCP_NODELAY on 803 ms, MQTT, broker defaults 1,045 ms, HTTPS, HTTP/1.1 603 ms, HTTPS, HTTP/2 603 ms. A new connection on a 50 ms link: HTTPS 153 ms, MQTT 204 ms, MQTT with Mosquitto's defaults 294 ms From opening the connection, TLS handshake included, until the first message is acknowledged MQTT HTTPS each link has its own scale LAN, no added delay MQTT, TCP_NODELAY on 1.89 ms MQTT, broker defaults 42.9 ms HTTPS, HTTP/1.1 1.70 ms HTTPS, HTTP/2 1.83 ms 50 ms round trip MQTT, TCP_NODELAY on 204 ms · 4.1 RTT MQTT, broker defaults 294 ms · 5.9 RTT HTTPS, HTTP/1.1 153 ms · 3.1 RTT HTTPS, HTTP/2 153 ms · 3.1 RTT 200 ms round trip, 1 % loss MQTT, TCP_NODELAY on 803 ms · 4.0 RTT MQTT, broker defaults 1,045 ms · 5.2 RTT HTTPS, HTTP/1.1 603 ms · 3.0 RTT HTTPS, HTTP/2 603 ms · 3.0 RTT HTTPS needs 3 round trips (TCP, TLS, request), MQTT 4 (it also waits for CONNACK). With Nagle's algorithm left on, Mosquitto adds 241 ms on the 200 ms link; set_tcp_nodelay true removes it.
New connection, TLS 1.3 handshake, then one 256-byte message until its acknowledgement (MQTT: CONNECT, CONNACK, PUBLISH QoS 1, PUBACK; HTTPS: POST until the response). Median of 10 process runs × 5 connections. Each link has its own scale; RTT = round trips across the link at that link's delay.
Time from opening a connection to the first message acknowledged, per link. LAN, no added delay: MQTT, TCP_NODELAY on 1.89 ms, MQTT, broker defaults 42.9 ms, HTTPS, HTTP/1.1 1.70 ms, HTTPS, HTTP/2 1.83 ms. 50 ms round trip: MQTT, TCP_NODELAY on 204 ms, MQTT, broker defaults 294 ms, HTTPS, HTTP/1.1 153 ms, HTTPS, HTTP/2 153 ms. 200 ms round trip, 1 % loss: MQTT, TCP_NODELAY on 803 ms, MQTT, broker defaults 1,045 ms, HTTPS, HTTP/1.1 603 ms, HTTPS, HTTP/2 603 ms. A new connection on a 50 ms link: HTTPS 153 ms, MQTT 204 ms, MQTT with Mosquitto's defaults 294 ms From opening the connection, TLS handshake included, until the first message is acknowledged MQTT HTTPS each link has its own scale LAN, no added delay MQTT, TCP_NODELAY on 1.89 ms MQTT, broker defaults 42.9 ms HTTP/1.1 1.70 ms HTTP/2 1.83 ms 50 ms round trip MQTT, TCP_NODELAY on 204 ms · 4.1 RTT MQTT, broker defaults 294 ms · 5.9 RTT HTTP/1.1 153 ms · 3.1 RTT HTTP/2 153 ms · 3.1 RTT 200 ms round trip, 1 % loss MQTT, TCP_NODELAY on 803 ms · 4.0 RTT MQTT, broker defaults 1,045 ms · 5.2 RTT HTTP/1.1 603 ms · 3.0 RTT HTTP/2 603 ms · 3.0 RTT HTTPS needs 3 round trips (TCP, TLS, request), MQTT 4 (it also waits for CONNACK). With Nagle's algorithm left on, Mosquitto adds 241 ms on the 200 ms link; set_tcp_nodelay true removes it.
New connection, TLS 1.3 handshake, then one 256-byte message until its acknowledgement (MQTT: CONNECT, CONNACK, PUBLISH QoS 1, PUBACK; HTTPS: POST until the response). Median of 10 process runs × 5 connections. Each link has its own scale; RTT = round trips across the link at that link's delay.

Both pay a similar number of bytes, 5,388 B for MQTT and 4,722 B for HTTPS over HTTP/1.1, almost all of it the TLS handshake. About half of that is new: Go 1.24’s client offers the post-quantum hybrid key exchange X25519MLKEM768 by default, both servers accept it, and its key shares are 1,216 B in the ClientHello and 1,120 B in the ServerHello. In a separate check with it switched off (GODEBUG=tlsmlkem=0, LAN, 3 connections each), the same connections cost about 2.9 KB and 2.2 KB. The time is counted in round trips:

On a 200 ms mobile-like link with loss, a device spends 803 ms (MQTT) or 603 ms (HTTPS) before its first message is acknowledged. That is the real argument for long-lived connections, and MQTT’s design assumes one.

Delivery latency

Next: once connected, how long from publishing a message until a subscriber has it? For MQTT the subscriber is another MQTT client; for HTTPS it is a client holding a Server-Sent Events stream, which the server writes to when a POST arrives. Messages go one at a time, so nothing queues.

Delivery latency from publish to subscriber, median. LAN, no added delay: MQTT QoS 0 22 µs, MQTT QoS 1 21 µs, MQTT QoS 2 24 µs, HTTPS, HTTP/1.1 24 µs, HTTPS, HTTP/2 30 µs, HTTPS, new connection each 490 µs. 50 ms round trip: MQTT QoS 0 50.4 ms, MQTT QoS 1 50.4 ms, MQTT QoS 2 101 ms, HTTPS, HTTP/1.1 50.5 ms, HTTPS, HTTP/2 50.4 ms, HTTPS, new connection each 153 ms. 200 ms round trip, 1 % loss: MQTT QoS 0 200 ms, MQTT QoS 1 200 ms, MQTT QoS 2 401 ms, HTTPS, HTTP/1.1 201 ms, HTTPS, HTTP/2 201 ms, HTTPS, new connection each 603 ms. Delivery costs one round trip for most, two for MQTT QoS 2, three for a new HTTPS connection On the 50 ms link: 50.4 ms, 101 ms and 153 ms · from the publisher's send until the subscriber has it, one message at a time · median MQTT HTTPS each link has its own scale LAN, no added delay MQTT QoS 0 22 µs MQTT QoS 1 21 µs MQTT QoS 2 24 µs HTTP/1.1 24 µs HTTP/2 30 µs new connection each 490 µs 50 ms round trip MQTT QoS 0 50.4 ms · 1.0 RTT MQTT QoS 1 50.4 ms · 1.0 RTT MQTT QoS 2 101 ms · 2.0 RTT HTTP/1.1 50.5 ms · 1.0 RTT HTTP/2 50.4 ms · 1.0 RTT new connection each 153 ms · 3.1 RTT 200 ms round trip, 1 % loss MQTT QoS 0 200 ms · 1.0 RTT MQTT QoS 1 200 ms · 1.0 RTT MQTT QoS 2 401 ms · 2.0 RTT HTTP/1.1 201 ms · 1.0 RTT HTTP/2 201 ms · 1.0 RTT new connection each 603 ms · 3.0 RTT On the LAN every protocol delivers in tens of microseconds. On a slow link the network sets the time; the protocol only decides how many trips across it a message needs.
One message at a time, 256 bytes, from the publisher's send until the subscriber has it (MQTT subscriber, or an SSE stream for HTTPS). Median of 10 process runs × 60 messages. Each link has its own scale; RTT = round trips at that link's delay. The slowest 1 % are in the next figure.
Delivery latency from publish to subscriber, median. LAN, no added delay: MQTT QoS 0 22 µs, MQTT QoS 1 21 µs, MQTT QoS 2 24 µs, HTTPS, HTTP/1.1 24 µs, HTTPS, HTTP/2 30 µs, HTTPS, new connection each 490 µs. 50 ms round trip: MQTT QoS 0 50.4 ms, MQTT QoS 1 50.4 ms, MQTT QoS 2 101 ms, HTTPS, HTTP/1.1 50.5 ms, HTTPS, HTTP/2 50.4 ms, HTTPS, new connection each 153 ms. 200 ms round trip, 1 % loss: MQTT QoS 0 200 ms, MQTT QoS 1 200 ms, MQTT QoS 2 401 ms, HTTPS, HTTP/1.1 201 ms, HTTPS, HTTP/2 201 ms, HTTPS, new connection each 603 ms. Delivery costs one round trip for most, two for MQTT QoS 2, three for a new HTTPS connection On the 50 ms link: 50.4 ms, 101 ms and 153 ms · from the publisher's send until the subscriber has it, one message at a time · median MQTT HTTPS each link has its own scale LAN, no added delay MQTT QoS 0 22 µs MQTT QoS 1 21 µs MQTT QoS 2 24 µs HTTP/1.1 24 µs HTTP/2 30 µs new conn. each 490 µs 50 ms round trip MQTT QoS 0 50.4 ms · 1.0 RTT MQTT QoS 1 50.4 ms · 1.0 RTT MQTT QoS 2 101 ms · 2.0 RTT HTTP/1.1 50.5 ms · 1.0 RTT HTTP/2 50.4 ms · 1.0 RTT new conn. each 153 ms · 3.1 RTT 200 ms round trip, 1 % loss MQTT QoS 0 200 ms · 1.0 RTT MQTT QoS 1 200 ms · 1.0 RTT MQTT QoS 2 401 ms · 2.0 RTT HTTP/1.1 201 ms · 1.0 RTT HTTP/2 201 ms · 1.0 RTT new conn. each 603 ms · 3.0 RTT On the LAN every protocol delivers in tens of microseconds. On a slow link the network sets the time; the protocol only decides how many trips across it a message needs.
One message at a time, 256 bytes, from the publisher's send until the subscriber has it (MQTT subscriber, or an SSE stream for HTTPS). Median of 10 process runs × 60 messages. Each link has its own scale; RTT = round trips at that link's delay. The slowest 1 % are in the next figure.

On the LAN everything on an open connection takes tens of microseconds; the protocol barely shows. On the slow links the network decides, and the protocols line up by how many trips across the link a message needs:

Delivery latency on the 200 ms link with 1 % loss, median and 99th percentile: MQTT QoS 0 200 ms median, 606 ms p99, MQTT QoS 1 200 ms median, 609 ms p99, MQTT QoS 2 401 ms median, 827 ms p99, HTTPS, HTTP/1.1 201 ms median, 618 ms p99, HTTPS, HTTP/2 201 ms median, 853 ms p99, HTTPS, new connection each 603 ms median, 1,659 ms p99. With 1 % packet loss the slowest 1 % of messages arrive 405–653 ms late on every protocol 200 ms link · the median stays at the round trips; a lost packet is resent only after a timeout MQTT median MQTT slowest 1 % HTTPS median HTTPS slowest 1 % MQTT QoS 0 200 ms → 606 ms MQTT QoS 1 200 ms → 609 ms MQTT QoS 2 401 ms → 827 ms HTTP/1.1 201 ms → 618 ms HTTP/2 201 ms → 853 ms new connection each 603 ms → 1,659 ms Both protocols ride the same TCP, so both wait the same retransmission timeout (at least 200 ms plus a round trip). Neither QoS level nor HTTP version helps with loss.
Same measurement, 200 ms round trip with 1 % random loss in each direction. Solid bar: median; lighter extension: each run's 99th percentile, median across 10 runs. On the 50 ms link without loss the 99th percentile is within 1 ms of the median for every row (MQTT QoS 1 51.0 ms, HTTP/1.1 51.0 ms).
Delivery latency on the 200 ms link with 1 % loss, median and 99th percentile: MQTT QoS 0 200 ms median, 606 ms p99, MQTT QoS 1 200 ms median, 609 ms p99, MQTT QoS 2 401 ms median, 827 ms p99, HTTPS, HTTP/1.1 201 ms median, 618 ms p99, HTTPS, HTTP/2 201 ms median, 853 ms p99, HTTPS, new connection each 603 ms median, 1,659 ms p99. With 1 % packet loss the slowest 1 % of messages arrive 405–653 ms late on every protocol 200 ms link · the median stays at the round trips; a lost packet is resent only after a timeout MQTT median MQTT slowest 1 % HTTPS median HTTPS slowest 1 % MQTT QoS 0 median 200 ms · slowest 1 %: 606 ms MQTT QoS 1 median 200 ms · slowest 1 %: 609 ms MQTT QoS 2 median 401 ms · slowest 1 %: 827 ms HTTP/1.1 median 201 ms · slowest 1 %: 618 ms HTTP/2 median 201 ms · slowest 1 %: 853 ms new conn. each median 603 ms · slowest 1 %: 1,659 ms Both protocols ride the same TCP, so both wait the same retransmission timeout (at least 200 ms plus a round trip). Neither QoS level nor HTTP version helps with loss.
Same measurement, 200 ms round trip with 1 % random loss in each direction. Solid bar: median; lighter extension: each run's 99th percentile, median across 10 runs. On the 50 ms link without loss the 99th percentile is within 1 ms of the median for every row (MQTT QoS 1 51.0 ms, HTTP/1.1 51.0 ms).

Loss shows up in the tail. On the 200 ms link with 1 % loss the medians stay at the round trips, 200 ms for MQTT QoS 1 and 201 ms for HTTP/1.1, but the 99th percentile reaches 609 ms and 618 ms: a lost TCP segment is retransmitted only after a timeout of at least 200 ms plus the round trip. Both protocols sit on the same TCP and suffer the same way; neither QoS level nor HTTP version helps with it.

The TCP_NODELAY broker changes nothing here (QoS 1: 50.3 ms on the 50 ms link): with one message in flight there is no second small packet for Nagle to hold back.

Throughput on one connection

How many messages per second can one connection carry from a publisher to a subscriber? The publisher sends as fast as each protocol allows for 3 seconds on the LAN and 10 seconds on the slow links; the rate is messages delivered to the subscriber per second, median and min–max across runs (nodelay: the broker with set_tcp_nodelay; HTTP/1.1 sends one request at a time, HTTP/2 keeps 100 in flight). The 50 ms link first, where the differences are widest:

Messages delivered per second on one connection over the 50 ms link, log scale: MQTT QoS 0 · no acknowledgements 62,035, MQTT QoS 1 · 20 in flight, nodelay 395, MQTT QoS 1 · 20 in flight, broker defaults 197, MQTT QoS 2 · nodelay 197, MQTT QoS 2 · broker defaults 98, HTTP/2 · 100 requests in flight 1,957, HTTP/1.1 · 1 request in flight 20. One connection, 50 ms link: HTTP/1.1 delivers 20 messages a second, MQTT QoS 1 197–395, HTTP/2 1,957, MQTT QoS 0 62,035 Log scale: each gridline is 10× the previous one · what limits each row is how many messages it may have in flight MQTT HTTPS 10 100 1,000 10,000 100,000 msg/s MQTT QoS 0 · no acknowledgements 62,035 MQTT QoS 1 · 20 in flight, nodelay 395 MQTT QoS 1 · 20 in flight, broker defaults 197 MQTT QoS 2 · nodelay 197 MQTT QoS 2 · broker defaults 98 HTTP/2 · 100 requests in flight 1,957 HTTP/1.1 · 1 request in flight 20 Header size does not set the ceiling on a slow link; the number of messages allowed in flight at once does. QoS 0 has no limit and no back-pressure either.
Publisher sending as fast as the protocol allows for 10 s on the 50 ms link, messages delivered to the subscriber per second, median of 10 runs. Log scale: each gridline is 10× the previous one. The table below has all three links with min–max.
Messages delivered per second on one connection over the 50 ms link, log scale: MQTT QoS 0 · no acknowledgements 62,035, MQTT QoS 1 · 20 in flight, nodelay 395, MQTT QoS 1 · 20 in flight, broker defaults 197, MQTT QoS 2 · nodelay 197, MQTT QoS 2 · broker defaults 98, HTTP/2 · 100 requests in flight 1,957, HTTP/1.1 · 1 request in flight 20. One connection, 50 ms link: HTTP/1.1 delivers 20 messages a second, MQTT QoS 1 197–395, HTTP/2 1,957, MQTT QoS 0 62,035 Log scale: each gridline is 10× the previous one · what limits each row is how many messages it may have in flight MQTT HTTPS 10 100 1,000 10,000 100,000 msg/s MQTT QoS 0 · no acknowledgements 62,035 MQTT QoS 1 · 20 in flight, nodelay 395 MQTT QoS 1 · 20 in flight, broker defaults 197 MQTT QoS 2 · nodelay 197 MQTT QoS 2 · broker defaults 98 HTTP/2 · 100 requests in flight 1,957 HTTP/1.1 · 1 request in flight 20 Header size does not set the ceiling on a slow link; the number of messages allowed in flight at once does. QoS 0 has no limit and no back-pressure either.
Publisher sending as fast as the protocol allows for 10 s on the 50 ms link, messages delivered to the subscriber per second, median of 10 runs. Log scale: each gridline is 10× the previous one. The table below has all three links with min–max.
Messages/sLAN50 ms200 ms
1 % loss
MQTT QoS 0277k
248k–281k
62k
62k–63k
542
258–844
MQTT QoS 1129k
128k–131k
197
197–198
45
42–48
MQTT QoS 267k
64k–67k
98
98–98
23
21–24
MQTT QoS 1
nodelay
119k
119k–120k
395
393–396
67
61–72
MQTT QoS 2
nodelay
63k
62k–64k
197
196–198
33
30–37
HTTP/1.158k
57k–62k
20
20–20
5
5–5
HTTP/2
100 streams
88k
84k–92k
1,957
1,933–1,970
238
205–257

On the LAN this measures software: TLS, the broker, the HTTP stack. On the slow links it measures how many messages each protocol allows in flight at once, and the differences become orders of magnitude:

For a sensor sending one reading a minute none of this matters. It matters for a gateway forwarding thousands of devices over one uplink, where the in-flight window, not the protocol’s header size, sets the ceiling.

One message to many subscribers

The publish–subscribe case: one message, delivered to 1, 10, 100 or 1,000 subscribers, each on its own TLS connection. For HTTPS each subscriber holds an SSE stream over HTTP/1.1 and the publisher POSTs once.

Time until every subscriber has a published message, for 1, 10, 100 and 1000 subscribers. LAN, no added delay: MQTT QoS 0 37 µs, 52 µs, 325 µs, 3.37 ms; MQTT QoS 1 40 µs, 54 µs, 426 µs, 4.99 ms; HTTPS + SSE 51 µs, 67 µs, 263 µs, 3.48 ms. 50 ms round trip: MQTT QoS 0 50.4 ms, 50.5 ms, 51.1 ms, 53.6 ms; MQTT QoS 1 50.3 ms, 50.5 ms, 51.2 ms, 52.9 ms; HTTPS + SSE 50.6 ms, 50.4 ms, 50.8 ms, 55.2 ms. 200 ms round trip, 1 % loss: MQTT QoS 0 200 ms, 200 ms, 608 ms, 620 ms; MQTT QoS 1 200 ms, 201 ms, 608 ms, 628 ms; HTTPS + SSE 201 ms, 201 ms, 607 ms, 624 ms. 1,000 subscribers all served in 3.37 ms (MQTT) and 3.48 ms (HTTPS) on the LAN; with 1 % loss both take about 620 ms One publish, every subscriber on its own TLS connection · time until the last subscriber has it MQTT QoS 0 HTTPS + SSE each link has its own scale LAN, no added delay 1 subscriber · MQTT QoS 0 37 µs SSE 51 µs 10 subscribers · MQTT QoS 0 52 µs SSE 67 µs 100 subscribers · MQTT QoS 0 325 µs SSE 263 µs 1,000 subscribers · MQTT QoS 0 3.37 ms SSE 3.48 ms 200 ms round trip, 1 % loss 1 subscriber · MQTT QoS 0 200 ms SSE 201 ms 10 subscribers · MQTT QoS 0 200 ms SSE 201 ms 100 subscribers · MQTT QoS 0 608 ms SSE 607 ms 1,000 subscribers · MQTT QoS 0 620 ms SSE 624 ms The two behave alike: the cost is the server writing one encrypted copy per subscriber, about 403 B each. On a lossy link some copy is almost always lost and the last subscriber waits for its retransmission.
One publish reaching every subscriber, each on its own TLS connection; the time until the last one has it, median of 10 process runs × 20 publishes. Each link has its own scale. Not drawn: the 50 ms link, where 1,000 subscribers take 53.6 ms (MQTT QoS 0) and 55.2 ms (SSE), and MQTT QoS 1, which tracks QoS 0 (4.99 ms for 1,000 subscribers on the LAN).
Time until every subscriber has a published message, for 1, 10, 100 and 1000 subscribers. LAN, no added delay: MQTT QoS 0 37 µs, 52 µs, 325 µs, 3.37 ms; MQTT QoS 1 40 µs, 54 µs, 426 µs, 4.99 ms; HTTPS + SSE 51 µs, 67 µs, 263 µs, 3.48 ms. 50 ms round trip: MQTT QoS 0 50.4 ms, 50.5 ms, 51.1 ms, 53.6 ms; MQTT QoS 1 50.3 ms, 50.5 ms, 51.2 ms, 52.9 ms; HTTPS + SSE 50.6 ms, 50.4 ms, 50.8 ms, 55.2 ms. 200 ms round trip, 1 % loss: MQTT QoS 0 200 ms, 200 ms, 608 ms, 620 ms; MQTT QoS 1 200 ms, 201 ms, 608 ms, 628 ms; HTTPS + SSE 201 ms, 201 ms, 607 ms, 624 ms. 1,000 subscribers all served in 3.37 ms (MQTT) and 3.48 ms (HTTPS) on the LAN; with 1 % loss both take about 620 ms One publish, every subscriber on its own TLS connection · time until the last subscriber has it MQTT QoS 0 HTTPS + SSE each link has its own scale LAN, no added delay 1 · MQTT QoS 0 37 µs SSE 51 µs 10 · MQTT QoS 0 52 µs SSE 67 µs 100 · MQTT QoS 0 325 µs SSE 263 µs 1,000 · MQTT QoS 0 3.37 ms SSE 3.48 ms 200 ms round trip, 1 % loss 1 · MQTT QoS 0 200 ms SSE 201 ms 10 · MQTT QoS 0 200 ms SSE 201 ms 100 · MQTT QoS 0 608 ms SSE 607 ms 1,000 · MQTT QoS 0 620 ms SSE 624 ms The two behave alike: the cost is the server writing one encrypted copy per subscriber, about 403 B each. On a lossy link some copy is almost always lost and the last subscriber waits for its retransmission.
One publish reaching every subscriber, each on its own TLS connection; the time until the last one has it, median of 10 process runs × 20 publishes. Each link has its own scale. Not drawn: the 50 ms link, where 1,000 subscribers take 53.6 ms (MQTT QoS 0) and 55.2 ms (SSE), and MQTT QoS 1, which tracks QoS 0 (4.99 ms for 1,000 subscribers on the LAN).

The two behave alike. On the LAN the cost is the server encrypting and writing one copy per subscriber: 3.37 ms for the last of 1,000 subscribers over MQTT QoS 0 and 3.48 ms over SSE, with Mosquitto’s single thread against Go’s server on the same single core. On the wire each extra subscriber costs about the same in both, 403 B and 396 B per subscriber for a 256-byte message.

On the lossy link, delivering to everyone becomes slow: with 1,000 subscribers some packet is almost always lost, and the publish waits for its retransmission. Half of the subscribers have the message after 203 ms (MQTT QoS 0), the last after 620 ms; SSE: 204 ms and 624 ms.

The cost of an idle client

Most IoT clients spend most of their time with nothing to say. They still have to stay reachable, and that costs something.

Bytes per hour to keep one idle client connected or up to date: MQTT keep-alive every 60 s · push 12.2 KB, SSE heartbeat every 60 s · push 8.0 KB, HTTP/2 poll every 60 s · up to 60 s late 15.0 KB, HTTP/1.1 poll every 60 s · up to 60 s late 21.8 KB, HTTP/1.1 poll every 10 s · up to 10 s late 130.7 KB, HTTP/1.1 poll every second 1.31 MB. An hour of staying reachable: MQTT keep-alive 12.2 KB, HTTP/1.1 polling every second 1.31 MB Log scale: each gridline is 10× the previous one · push = the client gets a message the moment it is published MQTT HTTPS 1 KB 10 KB 100 KB 1 MB 10 MB per hour MQTT keep-alive every 60 s · push 12.2 KB SSE heartbeat every 60 s · push 8.0 KB HTTP/2 poll every 60 s · up to 60 s late 15.0 KB HTTP/1.1 poll every 60 s · up to 60 s late 21.8 KB HTTP/1.1 poll every 10 s · up to 10 s late 130.7 KB HTTP/1.1 poll every second 1.31 MB Per exchange the four are within a factor of three (134 B to 363 B). What differs is how often a poller must ask to be told promptly: every second costs 107× the keep-alive.
Measured per exchange on an open connection (10 process runs × 10 exchanges: PINGREQ and PINGRESP, an empty poll answered 204, a one-line SSE comment), all headers and TCP acknowledgements included, then multiplied out to an hour. Log scale: each gridline is 10× the previous one.
Bytes per hour to keep one idle client connected or up to date: MQTT keep-alive every 60 s · push 12.2 KB, SSE heartbeat every 60 s · push 8.0 KB, HTTP/2 poll every 60 s · up to 60 s late 15.0 KB, HTTP/1.1 poll every 60 s · up to 60 s late 21.8 KB, HTTP/1.1 poll every 10 s · up to 10 s late 130.7 KB, HTTP/1.1 poll every second 1.31 MB. An hour of staying reachable: MQTT keep-alive 12.2 KB, HTTP/1.1 polling every second 1.31 MB Log scale: each gridline is 10× the previous one · push = the client gets a message the moment it is published MQTT HTTPS 1 KB 10 KB 100 KB 1 MB 10 MB per hour MQTT keep-alive every 60 s · push 12.2 KB SSE heartbeat every 60 s · push 8.0 KB HTTP/2 poll every 60 s · up to 60 s late 15.0 KB HTTP/1.1 poll every 60 s · up to 60 s late 21.8 KB HTTP/1.1 poll every 10 s · up to 10 s late 130.7 KB HTTP/1.1 poll every second 1.31 MB Per exchange the four are within a factor of three (134 B to 363 B). What differs is how often a poller must ask to be told promptly: every second costs 107× the keep-alive.
Measured per exchange on an open connection (10 process runs × 10 exchanges: PINGREQ and PINGRESP, an empty poll answered 204, a one-line SSE comment), all headers and TCP acknowledgements included, then multiplied out to an hour. Log scale: each gridline is 10× the previous one.

One keep-alive exchange, PINGREQ and PINGRESP with TLS and TCP around them, is 204 B in 3 packets; at the common 60-second keep-alive that is 12.2 KB an hour. An SSE heartbeat is cheaper still, 134 B, because it is one-way. An empty HTTP/1.1 poll costs 363 B and HTTP/2 249 B.

The difference that matters is not the bytes per exchange, which are within a factor of three, but what the client gets for them. A client on MQTT or SSE receives a message the moment it is published. A client that polls every 60 seconds learns about it up to a minute late; to get within a second it must poll every second, 1.31 MB an hour, 107× the MQTT keep-alive, and wake its radio 3,600 times.

What this does not show

What the numbers say

Reproduce it

The harness is a Go program (the MQTT client, the HTTPS client and the HTTPS server, standard library only), two Mosquitto configuration files and a driver script. It builds one image, starts the brokers and the server in the client’s network namespace, and runs every cell as a fresh client process:

./certs.sh                 # throwaway CA and ECDSA P-256 certificate for localhost
docker build -t mqb .      # Go 1.24 build, runs a self-test of the MQTT encoder
./up.sh 4-7 2 2            # client cores, broker core, HTTPS server core
docker exec mq-net tc qdisc replace dev lo root netem delay 25ms limit 100000   # the 50 ms link
docker exec mq-net mb run -test lat -kind mqtt -qos 1 -n 60 -settle 300ms

Each run prints one JSON line with every latency sample, the bytes and packets counted, and the check results: messages sent, received, corrupted, duplicated and missing.

Questions? Let's Chat :)

protocols