HTTP [1]
HTTP over TCP
How HTTP uses TCP connections?
- The browser extracts the hostname
- The browser looks up the IP address for this hostname (DNS)
- The browser get the port number (80)
- The browser makes a TCP connection to XX.XX.XX.XX port 80
- The browser sends an HTTP GET request message to the server
- The browser reads the HTTP response message from the server
- The browser closes the connection
Delays, bottlenecks and clogs in TCP connections
-
Notice that the transaction processing time can be quite small compared to the time required to set up TCP connections and transfer the request and response messages.
- DNS lookup delay
- Connection setup delay, occurring for every new TCP connection (TCP Slow Start)
- Request message transfer delay
- Response message transfer delay
-
Most common TCP-related delays affecting HTTP programmers
-
The TCP connection setup handshake
When payload is small (usually condition), setup handshake become big.
-
TCP slow-start congestion control
Because of TCP slow-start feature, new connections are slower than “tuned” connections. HTTP’s open-transfer-close communication model is doomed to be slow. Fortunately we have HTTP persistent connections.
-
Nagle’s algorithm for data aggregation
Nagle’s algorithm attempts to bundle up a large amount of TCP data before sending a packet. But small HTTP messages may not fill a packet, so they me be delayed waiting additional data that will never arrive. And Nagle’s algorithm will hold up the sending of data until an acknowledgment. but the acknowledgment itself will be delayed 100-200 ms by the daleyed acknowledgment algorithm. You can disable Nagle’s algorithm by setting TCP_NODELAY parameter of TCP protocol stack.
-
TCP’s delay acknowledgment algorithm for piggybacked acknowledgments
TCP’s piggybacking can make more efficient use of the network, but HTTP’s request-reply behavior reduces the chances that piggybacking can occur.
-
TIME_WAIT delays and port exhaustion
-