System Design
2. Networking FundamentalsAnimated
Keep-Alive Connections
Keeping a TCP connection open for several requests.
The idea
Instead of closing after each response, the connection stays open for a time, saving handshake cost.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- client
- gateway / proxy
- service
- cache
- data store
- queue / stream
Open one TCP connection and pay the handshake once.
- step:
- 1/4
- at:
- Client
1/9
The green dot is a request moving through the system.
Step by step
- 1Client opens a connection
- 2It sends a request and gets a reply
- 3The connection stays open
- 4The next request reuses it
Where it is used
HTTP clients and proxies.
Watch out for
Idle timeouts must match between client, proxy and server or requests fail randomly.