Communication / 4 / 5
Real-time updates
A chat must show a new message the moment it is sent. Polling, long polling, Server-Sent Events and WebSockets, and what it takes to run many open connections.
- 13 min
- Intermediate
- 11 steps
- Requests
- 50 000 /s
- Delivery delay
- 1 000 ms
- Missed
- 0 /min
- request
- reply
- redelivery
- duplicate
- lost
Numbers are a model scenario, not measurements
The real request
Bob → Chat serverRequest
GET /rooms/r_17/updates?since=m_730 HTTP/1.11
Host: chat.example.com
Authorization: hidden
Response
HTTP/1.1 200 OK
{
"messages": 2[]
}
since— The last message the client has. The server returns only newer ones.messages— Empty. The server read the database and spent a request to say “nothing”.
Course: 42 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes