Polling vs server-sent events

With polling each browser asks for news every second, even when there is none. With server-sent events the server sends each update on one open stream. For 20,000 browsers that get an update every 10 s, polling floods the server and the stream keeps p99 under 150 ms.

Play the level

Connections and streamsDrag or use arrow keys to change the protocol

HTTP/1.1 · connections: 6 · 30 files in 7 round trips, 630 ms

Case 1

20,000 browsers watch a status feed. Each gets an update about every 10 s, and it must arrive within 1 s. Browsers never send on this channel.

Case 1
Measure Goal Polling every second Server-sent events
p99 latency under 150 ms 8.2 s Fail 69 ms Pass
Monthly cost 8 USD/mo 8 USD/mo
Error rate 81.8% 0%
HTTP/2UsersWebSocket g…1 vCPU · 2 GB
HTTP/2UsersWebSocket g…1 vCPU · 2 GB
Polling every second: misses a goal
SSEUsersWebSocket g…1 vCPU · 2 GB
SSEUsersWebSocket g…1 vCPU · 2 GB
Server-sent events: meets the goals