w客户端、服务器超载
HTTP The Definitive Guide
与建立TCP连接以及传输请求和相应报文的时间相比,事务处理的时间是很短的。除非客户端或服务器超载或正在处理复杂
的动态资源,否则HTTP时延主要就是由TCP网络时延构成的。
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. Unless the client or server is
overloaded or executing complex dynamic resources, most HTTP delays are caused by TCP network
delays.
There are several possible causes of delay in an HTTP transaction:
1.
A client first needs to determine the IP address and port number of the web server from the
URI. If the hostname in the URI was not recently visited, it may take tens of seconds to
convert the hostname from a URI into an IP address using the DNS resolution infrastructure.
[3]
[3]
Luckily, most HTTP clients keep a small DNS cache of IP addresses for recently accessed sites.
When the IP address is already "cached" (recorded) locally, the lookup is instantaneous. Because
most web browsing is to a small number of popular sites, hostnames usually are resolved very
quickly.
2.
Next, the client sends a TCP connection request to the server and waits for the server to send
back a connection acceptance reply. Connection setup delay occurs for every new TCP
connection. This usually takes at most a second or two, but it can add up quickly when
hundreds of HTTP transactions are made.
3.
Once the connection is established, the client sends the HTTP request over the newly
established TCP pipe. The web server reads the request message from the TCP connection as
the data arrives and processes the request. It takes time for the request message to travel over
the Internet and get processed by the server.
4.
The web server then writes back the HTTP response, which also takes time.
The magnitude of these TCP network delays depends on hardware speed, the load of the network and
server, the size of the request and response messages, and the distance between client and server. The
delays also are significantly affected by technical intricacies of the TCP protocol.