System Design
10. API Design and ManagementAnimated
Long Polling
Hold a request open until there is data.
The idea
The client asks, the server waits until an update exists, then responds, and the client asks again.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- current message
- earlier
- failure or attack
The client asks for news.
- step:
- 1/4
- from:
- Client
- to:
- Server
1/4
Time runs downward. Solid arrows are requests, dashed arrows are replies.
Step by step
- 1Client sends a request
- 2Server holds it
- 3An event arrives
- 4Server responds and the client re-requests
Where it is used
Simple near-real-time updates.
Watch out for
Many held connections and timeouts.