WebSocket vs SSE vs long-polling vs MQTT benchmarks: pushing events to clients

Networking

A server that has something new for its clients has four common ways to tell them. It can keep a WebSocket open and write a message; keep an HTTP response open as a Server-Sent Events (SSE) stream and write a line; leave a client’s long-poll request hanging and answer it when there is news; or publish to an MQTT broker, which forwards to every subscribed client, in a browser over MQTT-over-WebSocket. All four run over TCP and TLS, so the interesting differences are in what each adds on top: framing, round trips, and what happens when a connection drops. (MQTT is explained in its own article; MQTT vs HTTPS measures the other direction, devices sending to a server.)

Everything below was measured on one machine, in Docker, with one server implementation family, the same TLS settings and certificate, and the same emulated links. Every event carries its sequence number and a payload derived from it, and every client checks every byte: 61,210,694 events delivered, 0 corrupted.

SetupDetails
Event serverGo 1.24.13, net/http + github.com/coder/websocket v1.8.15 (permessage-deflate off, its default), one process on one core · WebSocket at /ws, SSE at /sse, long-poll at /poll, all HTTP/1.1
MQTT brokerMosquitto 2.1.2 (eclipse-mosquitto:2), its own WebSocket listener with TLS for the clients, one core, defaults otherwise (20 messages in flight per client, 1,000 queued, Nagle’s algorithm on) · a second instance with set_tcp_nodelay true, the only setting changed, for the QoS 1 throughput and reconnect cells (nodelay) · the Go server publishes each event into it over TLS on the server’s loopback, so that hop never crosses the link
ClientsGo 1.24.13: coder/websocket, the net/http client for SSE and long-poll, a minimal MQTT 5 client over coder/websocket (one WebSocket message per MQTT packet) · every client on its own TLS connection
TLS1.3 everywhere, one ECDSA P-256 certificate, key exchange X25519MLKEM768 (Go’s default), no session resumption
Event32 bytes (a small JSON notification) or 1 KiB · framed as each protocol needs: one WebSocket text message; SSE id: + data: lines; long-poll: a 200 response whose body is the events since the client’s cursor; MQTT PUBLISH on a 2-byte topic
NetworkTwo network namespaces, server and client, on a Docker bridge at a 1,500-byte MTU, segmentation offloads off · links emulated with tc netem on both sides: LAN (nothing added), 50 ms round trip, 200 ms round trip with 1 % random loss in each direction
CPUAMD Ryzen AI Max+ 395 · cores 0–7 reserved for the benchmark · Go server on core 2, Mosquitto on core 3, clients on cores 4–7
MethodEvery cell is a fresh client process, run 5 times · reported value: median of the 5 run medians, with min–max · latency p99: each run’s 99th percentile, median across runs · bytes counted at the client for client↔server traffic only, IP packets with all headers, both directions · one warm-up event before measuring · a wait for a quiet link before every cell · TCP keep-alive probes off, so idle cost is the protocol’s own

The scoreboard

Scoreboard, median per mechanism. Latency, 50 ms link: WebSocket 25.2 ms, SSE 25.2 ms, Long-poll 25.1 ms, MQTT QoS 0 25.2 ms, MQTT QoS 1 25.3 ms. Bytes per 32-byte event: WebSocket 160 B, SSE 179 B, Long-poll 418 B, MQTT QoS 0 167 B, MQTT QoS 1 253 B. Bytes per 1 KiB event: WebSocket 1,154 B, SSE 1,172 B, Long-poll 1,412 B, MQTT QoS 0 1,162 B, MQTT QoS 1 1,248 B. Idle hour at default interval: WebSocket 25.2 KB, SSE 32.2 KB, Long-poll 41.6 KB, MQTT QoS 0 12.7 KB. Fan-out to 5,000 clients, LAN: WebSocket 57.9 ms, SSE 53.0 ms, Long-poll 73.1 ms, MQTT QoS 0 49.8 ms. Events/s, LAN: WebSocket 234,751, SSE 490,846, Long-poll 770,959, MQTT QoS 0 311,819, MQTT QoS 1 102,966. Events/s, 50 ms link: WebSocket 87,689, SSE 467,412, Long-poll 19,225, MQTT QoS 0 303,614, MQTT QoS 1 201. Catch-up after a drop, 200 ms: WebSocket 805 ms, SSE 606 ms, Long-poll 605 ms, MQTT QoS 1 2,187 ms. Best in every run, out of 8 measures: WebSocket on 1 · SSE on 1 · MQTT QoS 0 on 1; 5 have no fixed order Eight measures from the sections below · each mechanism as a multiple of the best WebSocket SSE Long-poll MQTT QoS 0 MQTT QoS 1 1× = the best median; grey line: lowest to highest run 1× (best) 10× 100× 1k× Latency, 50 ms link WebSocket 25.2 ms SSE 25.2 ms Long-poll 25.1 ms MQTT QoS 0 25.2 ms MQTT QoS 1 25.3 ms Bytes per 32-byte event WebSocket 160 B SSE 179 B Long-poll 418 B MQTT QoS 0 167 B MQTT QoS 1 253 B Bytes per 1 KiB event WebSocket 1,154 B SSE 1,172 B Long-poll 1,412 B MQTT QoS 0 1,162 B MQTT QoS 1 1,248 B Idle hour at default interval WebSocket 25.2 KB SSE 32.2 KB Long-poll 41.6 KB MQTT QoS 0 12.7 KB MQTT QoS 1 measured at QoS 0 only Fan-out to 5,000 clients, LAN WebSocket 57.9 ms SSE 53.0 ms Long-poll 73.1 ms MQTT QoS 0 49.8 ms MQTT QoS 1 measured at QoS 0 only Events/s, LAN WebSocket 234,751 SSE 490,846 Long-poll 770,959 MQTT QoS 0 311,819 MQTT QoS 1 102,966 Events/s, 50 ms link WebSocket 87,689 SSE 467,412 Long-poll 19,225 MQTT QoS 0 303,614 MQTT QoS 1 201 Catch-up after a drop, 200 ms WebSocket 805 ms SSE 606 ms Long-poll 605 ms MQTT QoS 0 QoS 0 has no persistent session MQTT QoS 1 2,187 ms Each bar is that mechanism's median as a multiple of the best median for the measure, log scale: 1× is the best, a bar twice as long is twice as costly. Grey line: lowest to highest of the 5 process runs; the median is printed after each bar.
Eight headline measures from the sections below, each mechanism's median as a multiple of the best median for that measure (1×; log scale, a longer bar is worse), labelled with the measured value. Median of 5 process runs; grey line: lowest to highest run. Bytes: both directions on an open connection. Idle hour: one keep-alive exchange at the interval named in that section. Fan-out: time until the last of 5,000 clients has the event. Catch-up: from the new dial until every missed event is in.
Scoreboard, median per mechanism. Latency, 50 ms link: WebSocket 25.2 ms, SSE 25.2 ms, Long-poll 25.1 ms, MQTT QoS 0 25.2 ms, MQTT QoS 1 25.3 ms. Bytes per 32-byte event: WebSocket 160 B, SSE 179 B, Long-poll 418 B, MQTT QoS 0 167 B, MQTT QoS 1 253 B. Bytes per 1 KiB event: WebSocket 1,154 B, SSE 1,172 B, Long-poll 1,412 B, MQTT QoS 0 1,162 B, MQTT QoS 1 1,248 B. Idle hour at default interval: WebSocket 25.2 KB, SSE 32.2 KB, Long-poll 41.6 KB, MQTT QoS 0 12.7 KB. Fan-out to 5,000 clients, LAN: WebSocket 57.9 ms, SSE 53.0 ms, Long-poll 73.1 ms, MQTT QoS 0 49.8 ms. Events/s, LAN: WebSocket 234,751, SSE 490,846, Long-poll 770,959, MQTT QoS 0 311,819, MQTT QoS 1 102,966. Events/s, 50 ms link: WebSocket 87,689, SSE 467,412, Long-poll 19,225, MQTT QoS 0 303,614, MQTT QoS 1 201. Catch-up after a drop, 200 ms: WebSocket 805 ms, SSE 606 ms, Long-poll 605 ms, MQTT QoS 1 2,187 ms. Best in every run, out of 8 measures: WebSocket on 1 · SSE on 1 · MQTT QoS 0 on 1; 5 have no fixed order Eight measures from the sections below · each mechanism as a multiple of the best WebSocket SSE Long-poll MQTT QoS 0 MQTT QoS 1 1× = the best median; grey line: lowest to highest run 1× (best) 10× 100× 1k× Latency, 50 ms link WebSocket 25.2 ms SSE 25.2 ms Long-poll 25.1 ms MQTT QoS 0 25.2 ms MQTT QoS 1 25.3 ms Bytes per 32-byte event WebSocket 160 B SSE 179 B Long-poll 418 B MQTT QoS 0 167 B MQTT QoS 1 253 B Bytes per 1 KiB event WebSocket 1,154 B SSE 1,172 B Long-poll 1,412 B MQTT QoS 0 1,162 B MQTT QoS 1 1,248 B Idle hour, default interval WebSocket 25.2 KB SSE 32.2 KB Long-poll 41.6 KB MQTT QoS 0 12.7 KB MQTT QoS 1 measured at QoS 0 only Fan-out to 5,000 clients, LAN WebSocket 57.9 ms SSE 53.0 ms Long-poll 73.1 ms MQTT QoS 0 49.8 ms MQTT QoS 1 measured at QoS 0 only Events/s, LAN WebSocket 234,751 SSE 490,846 Long-poll 770,959 MQTT QoS 0 311,819 MQTT QoS 1 102,966 Events/s, 50 ms link WebSocket 87,689 SSE 467,412 Long-poll 19,225 MQTT QoS 0 303,614 MQTT QoS 1 201 Catch-up after a drop, 200 ms WebSocket 805 ms SSE 606 ms Long-poll 605 ms MQTT QoS 0 QoS 0 has no persistent session MQTT QoS 1 2,187 ms Each bar is that mechanism's median as a multiple of the best median for the measure, log scale: 1× is the best, a bar twice as long is twice as costly. Grey line: lowest to highest of the 5 process runs; the median is printed after each bar.
Eight headline measures from the sections below, each mechanism's median as a multiple of the best median for that measure (1×; log scale, a longer bar is worse), labelled with the measured value. Median of 5 process runs; grey line: lowest to highest run. Bytes: both directions on an open connection. Idle hour: one keep-alive exchange at the interval named in that section. Fan-out: time until the last of 5,000 clients has the event. Catch-up: from the new dial until every missed event is in.
MeasureWebSocketSSELong-pollMQTT QoS 0MQTT QoS 1
Latency, 50 ms link25.2 ms
25.0–25.2 ms
25.2 ms
25.0–25.2 ms · same
25.1 ms
25.0–25.2 ms · same
25.2 ms
25.1–25.3 ms · same
25.3 ms
25.1–25.3 ms · same
Bytes per 32-byte event160 B
160–180 B
179 B
179 B · 0.89×
418 B
418 B · 0.38×
167 B
167 B · 0.96×
253 B
253 B · 0.63×
Bytes per 1 KiB event1,154 B
1,154 B
1,172 B
1,172 B · 0.98×
1,412 B
1,412 B · 0.82×
1,162 B
1,162 B · 0.99×
1,248 B
1,248 B · 0.92×
Idle hour at default interval25.2 KB
25.2 KB
32.2 KB
32.2 KB · 0.78×
41.6 KB
41.6 KB · 0.61×
12.7 KB
12.7 KB · 2.0×
measured at QoS 0 only
Fan-out to 5,000 clients, LAN57.9 ms
54.1–58.4 ms
53.0 ms
49.8–61.1 ms · 1.1×
73.1 ms
72.3–94.7 ms · 0.79×
49.8 ms
48.8–59.9 ms · 1.2×
measured at QoS 0 only
Events/s, LAN234,751
200,484–356,550
490,846
431,450–949,209 · 2.1×
770,959
611,181–804,090 · 3.3×
311,819
270,017–331,861 · 1.3×
102,966
90,977–104,139 · 0.44×
Events/s, 50 ms link87,689
79,622–271,356
467,412
431,523–475,372 · 5.3×
19,225
19,102–19,287 · 0.22×
303,614
130,641–320,344 · 3.5×
201
201 · 0.0023×
Catch-up after a drop, 200 ms805 ms
804–806 ms
606 ms
606 ms · 1.3×
605 ms
605–1,111 ms · 1.3×
QoS 0 has no persistent session2,187 ms
2,087–2,289 ms · 0.37×

Median of 5 process runs, lowest to highest run beneath; bold: best in every run; after the range, the factor against WebSocket: above 1× better than WebSocket, below 1× worse, same: rounds to 1×.

Counting a measure only where every run agrees, against WebSocket: SSE is better on 3 (up to 5.3× on events/s, 50 ms link), worse on 2 (down to 0.78× on idle hour at default interval) and ties on 3; Long-poll is better on 1 (up to 3.3× on events/s, LAN), worse on 5 (down to 0.22× on events/s, 50 ms link) and ties on 2; MQTT QoS 0 is better on 2 of its 7 (up to 3.5× on events/s, 50 ms link), worse on 1 (down to 0.99× on bytes per 1 KiB event) and ties on 4; MQTT QoS 1 is never better: worse on 5 of its 6 (down to 0.0023× on events/s, 50 ms link) and ties on 1. The sections below take each measure in turn, with the LAN and the lossy link, each direction of the bytes, the smaller fan-outs, the nodelay broker and the runs behind every median.

Factor against WebSocket per measure, above 1 is better than WebSocket. Latency, 50 ms link: SSE 1.0×, Long-poll 1.0×, MQTT QoS 0 1.00×, MQTT QoS 1 1.00×. Bytes per 32-byte event: SSE 0.89×, Long-poll 0.38×, MQTT QoS 0 0.96×, MQTT QoS 1 0.63×. Bytes per 1 KiB event: SSE 0.98×, Long-poll 0.82×, MQTT QoS 0 0.99×, MQTT QoS 1 0.92×. Idle hour at default interval: SSE 0.78×, Long-poll 0.61×, MQTT QoS 0 2.0×. Fan-out to 5,000 clients, LAN: SSE 1.1×, Long-poll 0.79×, MQTT QoS 0 1.2×. Events/s, LAN: SSE 2.1×, Long-poll 3.3×, MQTT QoS 0 1.3×, MQTT QoS 1 0.44×. Events/s, 50 ms link: SSE 5.3×, Long-poll 0.22×, MQTT QoS 0 3.5×, MQTT QoS 1 0.0023×. Catch-up after a drop, 200 ms: SSE 1.3×, Long-poll 1.3×, MQTT QoS 1 0.37×. Against WebSocket, 8 measures: SSE better on 3 · Long-poll on 1 · MQTT QoS 0 on 2 of its 7; never better: MQTT QoS 1 Medians of 5 process runs · log scale · above 1× is better than WebSocket SSE Long-poll MQTT QoS 0 MQTT QoS 1 0.01× 0.1× 1× (parity) Latency, 50 ms link SSE same Long-poll same MQTT QoS 0 same MQTT QoS 1 same Bytes per 32-byte event SSE 0.89× Long-poll 0.38× MQTT QoS 0 0.96× MQTT QoS 1 0.63× Bytes per 1 KiB event SSE 0.98× Long-poll 0.82× MQTT QoS 0 0.99× MQTT QoS 1 0.92× Idle hour at default interval SSE 0.78× Long-poll 0.61× MQTT QoS 0 2.0× MQTT QoS 1 measured at QoS 0 only Fan-out to 5,000 clients, LAN SSE 1.1× Long-poll 0.79× MQTT QoS 0 1.2× MQTT QoS 1 measured at QoS 0 only Events/s, LAN SSE 2.1× Long-poll 3.3× MQTT QoS 0 1.3× MQTT QoS 1 0.44× Events/s, 50 ms link SSE 5.3× Long-poll 0.22× MQTT QoS 0 3.5× MQTT QoS 1 0.0023× Catch-up after a drop, 200 ms SSE 1.3× Long-poll 1.3× MQTT QoS 0 QoS 0 has no persistent session MQTT QoS 1 0.37× ← WebSocket better the others better →
Each mechanism's median against WebSocket's on the same measure, log scale; above 1× it is better than WebSocket (faster, fewer bytes or more events per second). Median of 5 process runs.
Factor against WebSocket per measure, above 1 is better than WebSocket. Latency, 50 ms link: SSE 1.0×, Long-poll 1.0×, MQTT QoS 0 1.00×, MQTT QoS 1 1.00×. Bytes per 32-byte event: SSE 0.89×, Long-poll 0.38×, MQTT QoS 0 0.96×, MQTT QoS 1 0.63×. Bytes per 1 KiB event: SSE 0.98×, Long-poll 0.82×, MQTT QoS 0 0.99×, MQTT QoS 1 0.92×. Idle hour at default interval: SSE 0.78×, Long-poll 0.61×, MQTT QoS 0 2.0×. Fan-out to 5,000 clients, LAN: SSE 1.1×, Long-poll 0.79×, MQTT QoS 0 1.2×. Events/s, LAN: SSE 2.1×, Long-poll 3.3×, MQTT QoS 0 1.3×, MQTT QoS 1 0.44×. Events/s, 50 ms link: SSE 5.3×, Long-poll 0.22×, MQTT QoS 0 3.5×, MQTT QoS 1 0.0023×. Catch-up after a drop, 200 ms: SSE 1.3×, Long-poll 1.3×, MQTT QoS 1 0.37×. Against WebSocket, 8 measures: SSE better on 3 · Long-poll on 1 · MQTT QoS 0 on 2 of its 7; never better: MQTT QoS 1 Medians of 5 process runs · log scale · above 1× is better than WebSocket SSE Long-poll MQTT QoS 0 MQTT QoS 1 0.01× 0.1× 1× (parity) Latency, 50 ms link SSE same Long-poll same MQTT QoS 0 same MQTT QoS 1 same Bytes per 32-byte event SSE 0.89× Long-poll 0.38× MQTT QoS 0 0.96× MQTT QoS 1 0.63× Bytes per 1 KiB event SSE 0.98× Long-poll 0.82× MQTT QoS 0 0.99× MQTT QoS 1 0.92× Idle hour, default interval SSE 0.78× Long-poll 0.61× MQTT QoS 0 2.0× MQTT QoS 1 measured at QoS 0 only Fan-out to 5,000 clients, LAN SSE 1.1× Long-poll 0.79× MQTT QoS 0 1.2× MQTT QoS 1 measured at QoS 0 only Events/s, LAN SSE 2.1× Long-poll 3.3× MQTT QoS 0 1.3× MQTT QoS 1 0.44× Events/s, 50 ms link SSE 5.3× Long-poll 0.22× MQTT QoS 0 3.5× MQTT QoS 1 0.0023× Catch-up after a drop, 200 ms SSE 1.3× Long-poll 1.3× MQTT QoS 0 QoS 0 has no persistent session MQTT QoS 1 0.37× ← WebSocket better the others better →
Each mechanism's median against WebSocket's on the same measure, log scale; above 1× it is better than WebSocket (faster, fewer bytes or more events per second). Median of 5 process runs.

The four mechanisms

Delivery latency

From the server handing an event to the transport until the client has it, one event at a time:

Event delivery latency, median, per link. LAN, no added delay: WebSocket 82 µs, SSE 60 µs, Long-poll 70 µs, MQTT QoS 0 96 µs, MQTT QoS 1 133 µs. 50 ms round trip: WebSocket 25.2 ms, SSE 25.2 ms, Long-poll 25.1 ms, MQTT QoS 0 25.2 ms, MQTT QoS 1 25.3 ms. 200 ms round trip, 1 % loss: WebSocket 100 ms, SSE 100 ms, Long-poll 100 ms, MQTT QoS 0 100 ms, MQTT QoS 1 100 ms. Once connected, every option delivers in half a round trip: 25.2 ms on a 50 ms link, 100 ms on a 200 ms one Median delivery time, one event at a time · long-poll with its next request already waiting at the server · grey line: lowest to highest run from the app server through an MQTT broker each link has its own scale LAN, no added delay WebSocket 82 µs SSE 60 µs Long-poll 70 µs MQTT QoS 0 96 µs MQTT QoS 1 133 µs Run medians: WebSocket 38–219 µs, SSE 38–200 µs, long-poll 53–230 µs, MQTT QoS 0 84–380 µs, QoS 1 76–339 µs, all five overlapping, so their order is noise 50 ms round trip WebSocket 25.2 ms · 0.50 RTT SSE 25.2 ms · 0.50 RTT Long-poll 25.1 ms · 0.50 RTT MQTT QoS 0 25.2 ms · 0.50 RTT MQTT QoS 1 25.3 ms · 0.51 RTT 200 ms round trip, 1 % loss WebSocket 100 ms · 0.50 RTT SSE 100 ms · 0.50 RTT Long-poll 100 ms · 0.50 RTT MQTT QoS 0 100 ms · 0.50 RTT MQTT QoS 1 100 ms · 0.50 RTT On the LAN every median is at most 133 µs and the runs overlap, so the broker hop does not show at this scale. On a slow link the one- way delay is all there is, whichever protocol carries the event.
One 32-byte event at a time, from the server handing it to the transport until the client has it. Median of 5 process runs × 100 events (LAN) or 40 (slow links). Each link has its own scale; RTT = round trips at that link's delay. MQTT includes the hop from the event source into the broker, on the server's loopback.
Event delivery latency, median, per link. LAN, no added delay: WebSocket 82 µs, SSE 60 µs, Long-poll 70 µs, MQTT QoS 0 96 µs, MQTT QoS 1 133 µs. 50 ms round trip: WebSocket 25.2 ms, SSE 25.2 ms, Long-poll 25.1 ms, MQTT QoS 0 25.2 ms, MQTT QoS 1 25.3 ms. 200 ms round trip, 1 % loss: WebSocket 100 ms, SSE 100 ms, Long-poll 100 ms, MQTT QoS 0 100 ms, MQTT QoS 1 100 ms. Once connected, every option delivers in half a round trip: 25.2 ms on a 50 ms link, 100 ms on a 200 ms one Median delivery time, one event at a time · long-poll with its next request already waiting at the server · grey line: lowest to highest run from the app server through an MQTT broker each link has its own scale LAN, no added delay WebSocket 82 µs SSE 60 µs Long-poll 70 µs MQTT QoS 0 96 µs MQTT QoS 1 133 µs Run medians: WebSocket 38–219 µs, SSE 38–200 µs, long-poll 53–230 µs, MQTT QoS 0 84–380 µs, QoS 1 76–339 µs, all five overlapping, so their order is noise 50 ms round trip WebSocket 25.2 ms · 0.50 RTT SSE 25.2 ms · 0.50 RTT Long-poll 25.1 ms · 0.50 RTT MQTT QoS 0 25.2 ms · 0.50 RTT MQTT QoS 1 25.3 ms · 0.51 RTT 200 ms round trip, 1 % loss WebSocket 100 ms · 0.50 RTT SSE 100 ms · 0.50 RTT Long-poll 100 ms · 0.50 RTT MQTT QoS 0 100 ms · 0.50 RTT MQTT QoS 1 100 ms · 0.50 RTT On the LAN every median is at most 133 µs and the runs overlap, so the broker hop does not show at this scale. On a slow link the one-way delay is all there is, whichever protocol carries the event.
One 32-byte event at a time, from the server handing it to the transport until the client has it. Median of 5 process runs × 100 events (LAN) or 40 (slow links). Each link has its own scale; RTT = round trips at that link's delay. MQTT includes the hop from the event source into the broker, on the server's loopback.

On an open connection all four deliver in half a round trip: the event crosses the link once. On the 50 ms link that is 25.2 ms for WebSocket, 25.2 ms for SSE, 25.1 ms for long-poll and 25.2 ms for MQTT QoS 0. On the LAN every median is at most 133 µs, and the run medians overlap (WebSocket 38–219 µs, MQTT QoS 0 84–380 µs), so the extra hop through the broker, on the server’s loopback, does not show at this scale.

Long-poll matches the others here only because each event was sent after the client’s next request had arrived at the server. When events come closer together than one round trip, the second one waits for the client’s next request to arrive, and its latency grows from half a round trip towards a full one. The throughput section shows the same effect from the other side.

Delivery latency on the 200 ms link with 1 % loss, median and 99th percentile: WebSocket 100 ms median, 100 ms p99, SSE 100 ms median, 100 ms p99, Long-poll 100 ms median, 100 ms p99, MQTT QoS 0 100 ms median, 106 ms p99, MQTT QoS 1 100 ms median, 109 ms p99. With 1 % loss the median stays at 100 ms; an event that loses a packet waits for TCP to resend it, up to 598 ms 200 ms link · median and 99th percentile of all 200 events per protocol median slowest 1 % WebSocket 100 ms → 100 ms SSE 100 ms → 100 ms Long-poll 100 ms → 100 ms MQTT QoS 0 100 ms → 106 ms MQTT QoS 1 100 ms → 109 ms With 200 events per protocol, 1 % is two events: which rows caught a loss is chance, not a ranking. All four ride one TCP connection, and none can route around a lost segment.
Same measurement on the 200 ms link with 1 % random loss in each direction. Solid bar: median; lighter extension: 99th percentile of all 200 events of the 5 runs together (one run's 40 events are too few for a 1 % tail). On the 50 ms link without loss each run's 99th percentile stays within 0.2 ms of the median for every row.
Delivery latency on the 200 ms link with 1 % loss, median and 99th percentile: WebSocket 100 ms median, 100 ms p99, SSE 100 ms median, 100 ms p99, Long-poll 100 ms median, 100 ms p99, MQTT QoS 0 100 ms median, 106 ms p99, MQTT QoS 1 100 ms median, 109 ms p99. With 1 % loss the median stays at 100 ms; an event that loses a packet waits for TCP to resend it, up to 598 ms 200 ms link · median and 99th percentile of all 200 events per protocol median slowest 1 % WebSocket 100 ms → 100 ms SSE 100 ms → 100 ms Long-poll 100 ms → 100 ms MQTT QoS 0 100 ms → 106 ms MQTT QoS 1 100 ms → 109 ms With 200 events per protocol, 1 % is two events: which rows caught a loss is chance, not a ranking. All four ride one TCP connection, and none can route around a lost segment.
Same measurement on the 200 ms link with 1 % random loss in each direction. Solid bar: median; lighter extension: 99th percentile of all 200 events of the 5 runs together (one run's 40 events are too few for a 1 % tail). On the 50 ms link without loss each run's 99th percentile stays within 0.2 ms of the median for every row.

Loss shows in the tail. On the 200 ms link with 1 % loss the medians stay at the one-way delay, but the 99th percentile of all 200 events per protocol ranges from 100–109 ms. At that sample size a 1 % tail is two events, so the spread says which protocol happened to lose a packet, not which handles loss better: a lost TCP segment is resent only after a retransmission timeout, and everything behind it on the connection waits. MQTT’s QoS 1 acknowledgement does not help; it sits on the same TCP.

Bytes per event

On a connection that is already open, how many bytes does one event cost, counting both directions?

Bytes on the wire per event, server to client and client to server, IP headers included. 32-byte event: WebSocket 108 down + 52 up, SSE 127 down + 52 up, Long-poll 260 down + 158 up, MQTT QoS 0 115 down + 52 up, MQTT QoS 1 169 down + 84 up. 1024-byte event: WebSocket 1102 down + 52 up, SSE 1120 down + 52 up, Long-poll 1254 down + 158 up, MQTT QoS 0 1110 down + 52 up, MQTT QoS 1 1164 down + 84 up. A 32-byte event costs 160 B over WebSocket and 418 B over long-polling, which re-sends HTTP headers both ways for every event Bytes per event on an open connection, both directions, all headers included server → client client → server 32-byte event WebSocket 160 B · 108 + 52 SSE 179 B · 127 + 52 Long-poll 418 B · 260 + 158 MQTT QoS 0 167 B · 115 + 52 MQTT QoS 1 253 B · 169 + 84 1 KiB event WebSocket 1,154 B · 1,102 + 52 SSE 1,172 B · 1,120 + 52 Long-poll 1,412 B · 1,254 + 158 MQTT QoS 0 1,162 B · 1,110 + 52 MQTT QoS 1 1,248 B · 1,164 + 84 The streaming three differ by framing only: WebSocket 2 B per event, MQTT 9 B, SSE 21 B on top of TCP, IP and TLS. At 1 KiB that is noise; long-poll's headers are not.
Connection already open, one event at a time, both directions counted at the client (IP packets, all headers). Median of 5 process runs × 100 events (32 B) or 50 (1 KiB). Down: the event, as each protocol frames it, with TLS. Up: TCP acknowledgements, MQTT QoS 1's PUBACK, long-poll's next request.
Bytes on the wire per event, server to client and client to server, IP headers included. 32-byte event: WebSocket 108 down + 52 up, SSE 127 down + 52 up, Long-poll 260 down + 158 up, MQTT QoS 0 115 down + 52 up, MQTT QoS 1 169 down + 84 up. 1024-byte event: WebSocket 1102 down + 52 up, SSE 1120 down + 52 up, Long-poll 1254 down + 158 up, MQTT QoS 0 1110 down + 52 up, MQTT QoS 1 1164 down + 84 up. A 32-byte event costs 160 B over WebSocket and 418 B over long- polling, which re-sends HTTP headers both ways for every event Bytes per event on an open connection, both directions, all headers included server → client client → server 32-byte event WebSocket 160 B SSE 179 B Long-poll 418 B MQTT QoS 0 167 B MQTT QoS 1 253 B 1 KiB event WebSocket 1,154 B SSE 1,172 B Long-poll 1,412 B MQTT QoS 0 1,162 B MQTT QoS 1 1,248 B The streaming three differ by framing only: WebSocket 2 B per event, MQTT 9 B, SSE 21 B on top of TCP, IP and TLS. At 1 KiB that is noise; long-poll's headers are not.
Connection already open, one event at a time, both directions counted at the client (IP packets, all headers). Median of 5 process runs × 100 events (32 B) or 50 (1 KiB). Down: the event, as each protocol frames it, with TLS. Up: TCP acknowledgements, MQTT QoS 1's PUBACK, long-poll's next request.

Underneath every event is the same floor: 52 bytes of IPv4 and TCP headers per packet and 22 bytes of TLS framing per record, plus the 32-byte payload. On top of that:

At 1 KiB the framing is noise for the three streams, 1,154 B for WebSocket against 1,172 B for SSE, while long-poll still carries its 258 B of headers per event. The Go client’s request is lean (Host, User-Agent, Accept-Encoding); a browser’s, with cookies, is often a kilobyte more.

The cost of an idle connection

Most push connections spend most of their time silent. They still have to speak now and then, because proxies, load balancers and NAT routers close connections they think are dead. One keep-alive exchange per protocol, multiplied out to an hour at a common default interval:

Bytes per hour to keep one idle connection alive at common default intervals: WebSocket ping every 30 s 25.2 KB, SSE comment every 15 s 32.2 KB, long-poll answered empty every 30 s 41.6 KB, MQTT keep-alive every 60 s 12.7 KB. An idle hour: 12.7 KB for MQTT QoS 0, up to 41.6 KB for long-poll; the interval matters more than the protocol Bytes per hour per idle connection, both directions, at common default keep-alive intervals from the app server through an MQTT broker WebSocket ping every 30 s 25.2 KB · 210 B × 120 SSE comment every 15 s 32.2 KB · 134 B × 240 long-poll answered empty every 30 s 41.6 KB · 347 B × 120 MQTT keep-alive every 60 s 12.7 KB · 212 B × 60 Per exchange the four are within 2.6× of each other (134 B to 347 B). What a deployment pays is set by how often it must speak to stop proxies and NATs closing the connection.
One keep-alive exchange measured on an open connection (5 process runs × 10 exchanges, both directions, TCP acknowledgements included), multiplied out to an hour at the interval shown. MQTT here is MQTT over WebSocket.
Bytes per hour to keep one idle connection alive at common default intervals: WebSocket ping every 30 s 25.2 KB, SSE comment every 15 s 32.2 KB, long-poll answered empty every 30 s 41.6 KB, MQTT keep-alive every 60 s 12.7 KB. An idle hour: 12.7 KB for MQTT QoS 0, up to 41.6 KB for long- poll; the interval matters more than the protocol Bytes per hour per idle connection, both directions, at common default keep-alive intervals from the app server through an MQTT broker WebSocket · 30 s 25.2 KB SSE · 15 s 32.2 KB Long-poll · 30 s 41.6 KB MQTT QoS 0 · 60 s 12.7 KB Per exchange the four are within 2.6× of each other (134 B to 347 B). What a deployment pays is set by how often it must speak to stop proxies and NATs closing the connection.
One keep-alive exchange measured on an open connection (5 process runs × 10 exchanges, both directions, TCP acknowledgements included), multiplied out to an hour at the interval shown. MQTT here is MQTT over WebSocket.

The intervals are conventions, not part of the protocols: the HTML standard suggests an SSE comment about every 15 seconds; 30 seconds is a common WebSocket ping interval and a common long-poll hold time; 60 seconds is the usual MQTT keep-alive. Per exchange:

Even the most expensive is 41.6 KB an hour. Multiplied by a hundred thousand mostly idle clients it is not nothing, but the interval a deployment needs, set by the shortest timeout anywhere on the path, matters more than the protocol.

One event to many clients

One event, delivered to every connected client, each on its own TLS connection:

Time until the last client has an event, by number of clients. LAN, no added delay: WebSocket 82 µs, 1.50 ms, 5.95 ms, 57.9 ms; SSE 60 µs, 1.02 ms, 10.7 ms, 53.0 ms; Long-poll 70 µs, 1.65 ms, 12.9 ms, 73.1 ms; MQTT QoS 0 96 µs, 1.65 ms, 5.84 ms, 49.8 ms. 200 ms round trip, 1 % loss: WebSocket 100 ms, 527 ms, 559 ms; SSE 100 ms, 520 ms, 559 ms; Long-poll 100 ms, 517 ms, 631 ms; MQTT QoS 0 100 ms, 514 ms, 542 ms. 5,000 clients on the LAN: the last has the event after 49.8–73.1 ms; the server's one core is the limit One event, every client on its own TLS connection · time until the last client has it · 5,000 clients measured on the LAN only · grey line: lowest to highest run from the app server through an MQTT broker each link has its own scale LAN, no added delay 1 client · WebSocket 82 µs SSE 60 µs Long-poll 70 µs MQTT QoS 0 96 µs 100 clients · WebSocket 1.50 ms SSE 1.02 ms Long-poll 1.65 ms MQTT QoS 0 1.65 ms 1,000 clients · WebSocket 5.95 ms SSE 10.7 ms Long-poll 12.9 ms MQTT QoS 0 5.84 ms 5,000 clients · WebSocket 57.9 ms SSE 53.0 ms Long-poll 73.1 ms MQTT QoS 0 49.8 ms 5,000 clients, run medians: WebSocket 54.1–58.4 ms, SSE 49.8–61.1 ms, Long-poll 72.3–94.7 ms, MQTT 48.8–59.9 ms 200 ms round trip, 1 % loss 1 client · WebSocket 100 ms SSE 100 ms Long-poll 100 ms MQTT QoS 0 100 ms 100 clients · WebSocket 527 ms SSE 520 ms Long-poll 517 ms MQTT QoS 0 514 ms 1,000 clients · WebSocket 559 ms SSE 559 ms Long-poll 631 ms MQTT QoS 0 542 ms Which protocol's last client waited for a retransmission is chance: run medians 101–537 ms at 100, 529–713 ms at 1,000 clients Every option writes one encrypted copy per client, so time to the last grows with the count. At 5,000 the three streams overlap across runs (48.8–61.1 ms); long-poll, where each client also sends a new request after every event, is slowest by median (73.1 ms, runs 72.3–94.7 ms).
One event to every client, each on its own TLS connection, time until the last one has it; median of 5 process runs × 10 events (1 client: the latency cells). Each link has its own scale; on the lossy link the largest count is 1,000. The Go server and Mosquitto each run on one core.
Time until the last client has an event, by number of clients. LAN, no added delay: WebSocket 82 µs, 1.50 ms, 5.95 ms, 57.9 ms; SSE 60 µs, 1.02 ms, 10.7 ms, 53.0 ms; Long-poll 70 µs, 1.65 ms, 12.9 ms, 73.1 ms; MQTT QoS 0 96 µs, 1.65 ms, 5.84 ms, 49.8 ms. 200 ms round trip, 1 % loss: WebSocket 100 ms, 527 ms, 559 ms; SSE 100 ms, 520 ms, 559 ms; Long-poll 100 ms, 517 ms, 631 ms; MQTT QoS 0 100 ms, 514 ms, 542 ms. 5,000 clients on the LAN: the last has the event after 49.8–73.1 ms; the server's one core is the limit One event, every client on its own TLS connection · time until the last client has it · 5,000 clients measured on the LAN only · grey line: lowest to highest run from the app server through an MQTT broker each link has its own scale LAN, no added delay 1 · WebSocket 82 µs SSE 60 µs Long-poll 70 µs MQTT 96 µs 100 · WebSocket 1.50 ms SSE 1.02 ms Long-poll 1.65 ms MQTT 1.65 ms 1,000 · WebSocket 5.95 ms SSE 10.7 ms Long-poll 12.9 ms MQTT 5.84 ms 5,000 · WebSocket 57.9 ms SSE 53.0 ms Long-poll 73.1 ms MQTT 49.8 ms 5,000 clients, run medians: WebSocket 54.1–58.4 ms, SSE 49.8–61.1 ms, Long-poll 72.3–94.7 ms, MQTT 48.8–59.9 ms 200 ms round trip, 1 % loss 1 · WebSocket 100 ms SSE 100 ms Long-poll 100 ms MQTT 100 ms 100 · WebSocket 527 ms SSE 520 ms Long-poll 517 ms MQTT 514 ms 1,000 · WebSocket 559 ms SSE 559 ms Long-poll 631 ms MQTT 542 ms Which protocol's last client waited for a retransmission is chance: run medians 101–537 ms at 100, 529–713 ms at 1,000 clients Every option writes one encrypted copy per client, so time to the last grows with the count. At 5,000 the three streams overlap across runs (48.8–61.1 ms); long-poll, where each client also sends a new request after every event, is slowest by median (73.1 ms, runs 72.3–94.7 ms).
One event to every client, each on its own TLS connection, time until the last one has it; median of 5 process runs × 10 events (1 client: the latency cells). Each link has its own scale; on the lossy link the largest count is 1,000. The Go server and Mosquitto each run on one core.

All four write one encrypted copy per client, so the time until the last one has it grows with the number of clients, and with one core per server the core is what runs out. 5,000 clients were measured on the LAN only (the lossy link stopped at 1,000, to keep the run within its time budget). There the last client had the event after 49.8–57.9 ms for WebSocket, SSE and MQTT, whose runs overlap (48.8–61.1 ms across runs, so no order among the three), and 73.1 ms for long-poll (runs 72.3–94.7 ms), which also completes a request per client per event, and every client then sends a new one, which the same core has to take in.

On the lossy link, delivering to everyone means waiting for the unluckiest connection: with 1,000 clients some packet is almost always lost, and the last client waits for its retransmission (559 ms for WebSocket, half of the clients had it after 104 ms).

Events per second on one connection

How fast can one connection carry events, if the server has a backlog? The server emits 32-byte events as fast as each transport accepts them, 3 seconds on the LAN and 5 on the slow links:

Events delivered per second on one connection over the 50 ms link, log scale: WebSocket 87,689, SSE 467,412, Long-poll 19,225, MQTT QoS 0 303,614, MQTT QoS 1 201, MQTT QoS 1, nodelay 399. One connection, 50 ms link: MQTT QoS 1 delivers 201 events a second (399 with nodelay), the others 19,225–467,412 Log scale · QoS 1 waits for acknowledgements, at most 20 events in flight; the others only for TCP · nodelay: a second broker with set_tcp_nodelay true · grey line: lowest to highest run from the app server through an MQTT broker 100 1,000 10,000 100,000 1,000,000 events/s WebSocket 87,689 SSE 467,412 Long-poll 19,225 MQTT QoS 0 303,614 MQTT QoS 1 201 MQTT QoS 1, nodelay 399 A stream is limited by TCP's window, long-poll by one batch per round trip (at most 1,000 events here), and MQTT QoS 1 by the broker's in-flight limit of 20 unacknowledged messages per client; with Nagle's algorithm on (Mosquitto's default) it reaches 50 % of the nodelay rate.
The server emits 32-byte events as fast as the transport accepts them for 5 s on the 50 ms link; events delivered per second, median of 5 runs. Log scale: each gridline is 10× the previous one. Long-poll's response holds at most 1,000 events (this server's cap), so its ceiling on this link is 20,000/s. The table below has every link.
Events delivered per second on one connection over the 50 ms link, log scale: WebSocket 87,689, SSE 467,412, Long-poll 19,225, MQTT QoS 0 303,614, MQTT QoS 1 201, MQTT QoS 1, nodelay 399. One connection, 50 ms link: MQTT QoS 1 delivers 201 events a second (399 with nodelay), the others 19,225–467,412 Log scale · QoS 1 waits for acknowledgements, at most 20 events in flight; the others only for TCP · nodelay: a second broker with set_tcp_nodelay true · grey line: lowest to highest run from the app server through an MQTT broker events/s 100 1,000 10,000 100,000 1,000,000 WebSocket 87,689 SSE 467,412 Long-poll 19,225 MQTT QoS 0 303,614 MQTT QoS 1 201 QoS 1, nodelay 399 A stream is limited by TCP's window, long-poll by one batch per round trip (at most 1,000 events here), and MQTT QoS 1 by the broker's in-flight limit of 20 unacknowledged messages per client; with Nagle's algorithm on (Mosquitto's default) it reaches 50 % of the nodelay rate.
The server emits 32-byte events as fast as the transport accepts them for 5 s on the 50 ms link; events delivered per second, median of 5 runs. Log scale: each gridline is 10× the previous one. Long-poll's response holds at most 1,000 events (this server's cap), so its ceiling on this link is 20,000/s. The table below has every link.
Events/sLAN50 ms200 ms
1 % loss
WebSocket234,751
200,484–356,550
87,689
79,622–271,356
4,159
1,875–7,463
SSE490,846
431,450–949,209
467,412
431,523–475,372
3,968
1,883–5,983
Long-poll770,959
611,181–804,090
19,225
19,102–19,287
3,769
2,678–4,022
MQTT QoS 0311,819
270,017–331,861
303,614
130,641–320,344
2,488
1,332–5,370
MQTT QoS 1102,966
90,977–104,139
201
201–201
46
45–49
MQTT QoS 1
nodelay
104,510
91,274–105,326
399
398–399
69
67–72

On the LAN this measures software: TLS, framing, the broker. On the slow links it measures what each protocol lets be in flight:

The table counts only events delivered.

Reconnecting after a dropped connection

Connections drop: a phone changes network, a laptop sleeps, a proxy restarts. Here the client resets its TCP connection without warning, stays away for two seconds while the server keeps emitting 20 events a second, then reconnects and resumes:

Time from reconnecting until every event missed while away has arrived, per link: LAN, no added delay: WebSocket 5.71 ms, SSE 4.95 ms, Long-poll 4.67 ms, MQTT QoS 1 88.4 ms, MQTT QoS 1, nodelay 5.39 ms. 50 ms round trip: WebSocket 205 ms, SSE 155 ms, Long-poll 155 ms, MQTT QoS 1 538 ms, MQTT QoS 1, nodelay 307 ms. 200 ms round trip, 1 % loss: WebSocket 805 ms, SSE 606 ms, Long-poll 605 ms, MQTT QoS 1 2,187 ms, MQTT QoS 1, nodelay 1,207 ms. Back in sync after a drop, 200 ms link: 605–805 ms with a cursor, 2,187 ms for an MQTT persistent session (1,207 ms with nodelay) From the new dial until every missed event has arrived · about 42 events missed per drop · grey line: lowest to highest run from the app server through an MQTT broker each link has its own scale LAN, no added delay WebSocket 5.71 ms SSE 4.95 ms Long-poll 4.67 ms MQTT QoS 1 88.4 ms MQTT QoS 1, nodelay 5.39 ms Run medians: WebSocket, SSE, long-poll and nodelay all within 3.78–6.64 ms, so their order is noise · MQTT QoS 1 87.4–89.1 ms 50 ms round trip WebSocket 205 ms · 4.1 RTT SSE 155 ms · 3.1 RTT Long-poll 155 ms · 3.1 RTT MQTT QoS 1 538 ms · 10.8 RTT MQTT QoS 1, nodelay 307 ms · 6.1 RTT 200 ms round trip, 1 % loss WebSocket 805 ms · 4.0 RTT SSE 606 ms · 3.0 RTT Long-poll 605 ms · 3.0 RTT MQTT QoS 1 2,187 ms · 10.9 RTT MQTT QoS 1, nodelay 1,207 ms · 6.0 RTT Run medians: WebSocket 804–806 ms, SSE 606–606 ms, Long-poll 605–1,111 ms, MQTT QoS 1 2,087–2,289 ms, nodelay 1,207–1,459 ms; a run far above its row's others most likely lost a packet in the handshake or the replay A new TCP + TLS connection is the floor everywhere (2 round trips, plus 1 for the request). What follows depends on how the backlog is sent: in one response, one stream, or 20 acknowledged messages at a time.
A 20 events/s stream; the client resets its connection, stays away 2 s, reconnects and resumes: WebSocket with an app-level ?after= cursor, SSE with Last-Event-ID, long-poll with its cursor, MQTT with a persistent session at QoS 1. Time from the new dial until every event emitted before it is in; median of 5 process runs × 2 reconnects. Each link has its own scale.
Time from reconnecting until every event missed while away has arrived, per link: LAN, no added delay: WebSocket 5.71 ms, SSE 4.95 ms, Long-poll 4.67 ms, MQTT QoS 1 88.4 ms, MQTT QoS 1, nodelay 5.39 ms. 50 ms round trip: WebSocket 205 ms, SSE 155 ms, Long-poll 155 ms, MQTT QoS 1 538 ms, MQTT QoS 1, nodelay 307 ms. 200 ms round trip, 1 % loss: WebSocket 805 ms, SSE 606 ms, Long-poll 605 ms, MQTT QoS 1 2,187 ms, MQTT QoS 1, nodelay 1,207 ms. Back in sync after a drop, 200 ms link: 605–805 ms with a cursor, 2,187 ms for an MQTT persistent session (1,207 ms with nodelay) From the new dial until every missed event has arrived · about 42 events missed per drop · grey line: lowest to highest run from the app server through an MQTT broker each link has its own scale LAN, no added delay WebSocket 5.71 ms SSE 4.95 ms Long-poll 4.67 ms MQTT QoS 1 88.4 ms QoS 1, nodelay 5.39 ms Run medians: WebSocket, SSE, long-poll and nodelay all within 3.78–6.64 ms, so their order is noise · MQTT QoS 1 87.4–89.1 ms 50 ms round trip WebSocket 205 ms · 4.1 RTT SSE 155 ms · 3.1 RTT Long-poll 155 ms · 3.1 RTT MQTT QoS 1 538 ms · 10.8 RTT QoS 1, nodelay 307 ms · 6.1 RTT 200 ms round trip, 1 % loss WebSocket 805 ms · 4.0 RTT SSE 606 ms · 3.0 RTT Long-poll 605 ms · 3.0 RTT MQTT QoS 1 2,187 ms · 10.9 RTT QoS 1, nodelay 1,207 ms · 6.0 RTT Run medians: WebSocket 804–806 ms, SSE 606–606 ms, Long-poll 605–1,111 ms, MQTT QoS 1 2,087–2,289 ms, nodelay 1,207–1,459 ms; a run far above its row's others most likely lost a packet in the handshake or the replay A new TCP + TLS connection is the floor everywhere (2 round trips, plus 1 for the request). What follows depends on how the backlog is sent: in one response, one stream, or 20 acknowledged messages at a time.
A 20 events/s stream; the client resets its connection, stays away 2 s, reconnects and resumes: WebSocket with an app-level ?after= cursor, SSE with Last-Event-ID, long-poll with its cursor, MQTT with a persistent session at QoS 1. Time from the new dial until every event emitted before it is in; median of 5 process runs × 2 reconnects. Each link has its own scale.
After a dropLAN50 ms200 ms
1 % loss
Bytes to resume
(200 ms link)
WebSocket5.71 ms
4.80 ms–5.94 ms
205 ms
204 ms–205 ms
805 ms
804 ms–806 ms
8.3 KB
SSE4.95 ms
4.10 ms–5.51 ms
155 ms
155 ms–156 ms
606 ms
606 ms–606 ms
7.0 KB
Long-poll4.67 ms
3.78 ms–5.23 ms
155 ms
155 ms–155 ms
605 ms
605 ms–1,111 ms
6.4 KB
MQTT QoS 188.4 ms
87.4 ms–89.1 ms
538 ms
537 ms–539 ms
2,187 ms
2,087 ms–2,289 ms
13.3 KB
MQTT QoS 1
nodelay
5.39 ms
4.68 ms–6.64 ms
307 ms
306 ms–307 ms
1,207 ms
1,207 ms–1,459 ms
14.4 KB

Each mechanism resumes differently. SSE sends Last-Event-ID and the server replays everything newer in the same response. WebSocket has no built-in way; this client reconnects with ?after=<id>, and the server replays from its log, one frame per event. Long-poll simply polls with its cursor and gets the missed events as one response. MQTT reconnects to its persistent session (QoS 1, clean start off, session expiry one hour), and the broker sends what it queued while the client was away.

All four start with a new TCP and TLS connection, two round trips, and one more for the request that resumes. On the 200 ms link that floor is about 600 ms, where SSE (606 ms) and long-poll (605 ms) land. WebSocket (805 ms) takes one round trip more, on the 50 ms link too (205 ms against 155 ms for SSE). The likely reason, an explanation rather than a measurement: this server writes the replay as one frame per event, each its own TLS record and packet, more than the 10 packets a new TCP connection may send before the first acknowledgement; one write with all the events would remove it. MQTT’s broker sends the queue 20 acknowledged messages at a time, with Nagle’s algorithm slowing the refills as in the throughput section: 2,187 ms (1,207 ms with set_tcp_nodelay true), and QoS 1 is at-least-once: an event in flight at the moment of the drop may arrive twice, so a client must discard repeats by ID. In these runs it never happened: no mechanism delivered a duplicate, and none lost an event.

What none of the four measures is how long the client takes to notice the drop. Here it knew at once; in practice a silent network failure is found by the next missed keep-alive, which is why the idle intervals above exist. A browser’s EventSource also waits a few seconds before reconnecting unless the server sends a retry: field.

What this does not show

What the numbers say

Reproduce it

The harness is one Go program (the event server with its WebSocket, SSE and long-poll endpoints and MQTT publisher, and every client), a Mosquitto configuration and two shell scripts. It builds one image, starts the server and broker in one network namespace and the clients in another, and runs every cell as a fresh client process:

./certs.sh                       # throwaway CA and ECDSA P-256 certificate
docker build -t pushb .          # Go build, runs the self-test
PUSH_SUBNET=<a free private /28> ./up.sh 2 3 4-7    # server core, broker core, client cores
./link.sh l50                    # 25 ms each way
docker exec push-cli pb run -test push -kind sse -n 40 -pause 100ms

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

Questions? Let's Chat :)

protocols