WebSocket
A connection that stays open between client and server, where both can send data at any time.
Example
An online game sends and receives moves 30 times per second over 1 WebSocket.
Test yourself: WebSocket
Real time: long polling, WebSockets and SSE
WebSocket gives ___ communication: both sides send data at once.
In a chat, you write and receive over the same connection, without opening 2.
Real time: long polling, WebSockets and SSE
If a WebSocket connection drops, it recovers on its own.
You must reconnect yourself, for example retrying at 1, 2 and 4 seconds.
Designing WhatsApp
Why doesn't the pull model scale for a chat?
50 million users asking every 5 seconds is 10 million requests per second, almost all empty.
0/3
â–¶ Play