-
Difference between TCP keepalive and HTTP keepaliveWeb/Network 2019. 9. 28. 17:41
1. Overview
Let's distinguish the difference between TCP keepalive and HTTP keepalive.
2. Description
-
HTTP Keep-Alive
A feature that allows HTTP client (usually browser) and server (webserver) to send multiple request/response pairs over the same TCP connection. This decreases latency for 2nd, 3rd,... HTTP request, decreases network traffic and similar.
-
TCP keepalive
A totally different beast. It keeps TCP connection opened by sending small packets. Additionally, when the packet is sent this serves as a check so the sender is notified as soon as connection drops (note that this is NOT the case otherwise - until we try to communicate through TCP connection we have no idea if it is ok or not).
- How is HTTP Keep-Alive implemented?
To put it simply, the HTTP server doesn't close the TCP connection after each response but waits some time if some other HTTP request will come over it too. After some timeout, it closes it anyway.
- Does it internally use TCP Keep-Alive?
No.
- If not, how does the server detect if the client is dead or alive?
It doesn't - it doesn't need to. If a client sends a request, it will get the response. If the client doesn't send anything over TCP connection (maybe because the connection is dead) then a timeout will close the connection; a client will notice this and will send a request through another TCP connection if needed.
3. References
'Web > Network' 카테고리의 다른 글
Subnetworks and Subnetting (0) 2020.03.06 Domain Name Server (DNS), Iterative, and Recursive DNS Query (0) 2019.09.28 TCP Keepalive (0) 2019.09.28 TCP backlog with handshake (0) 2019.09.28 Data serialization and deserializaiton (0) 2019.09.27 -