HTTP Keep Alive vs TCP Persistent Connection

httptcp

What's the relationship between the two concepts?

Is one HTTP Keep-Alive connection always over a long persistent TCP connection? When the HTTP connection is closed, will the TCP connection be closed at the same time?

Or can multiple HTTP requests, including Keep-Alive ones, run over a single TCP connection?

Best Answer

Is one http keepalive connection always over a long persistent tcp connection

There is no such thing as a "persistent" TCP connection. All TCP connections persist from connection start to close.

When the http connection closed , will the tcp connection be closed at the same time?

There is no concept of "close connection" for HTTP. HTTP knows only requests and responses and an exchange is done the request is fully send and the response is fully received. With keep-alive you can have multiple such exchanges inside a single TCP connection.

Close of TCP connection means close of HTTP connection, but there is no explicit close of the HTTP connection.

Related Topic