The effect of delay-tcp on HTTP transactions

Source: Internet
Author: User
Tags ack

reading: Recently read the voluminous book "http authoritative guide", for such guide class, manual books, often let us think of is boring use explanation, technical indicators explained ... Make a big head. But this book makes me feel very "fresh", on the one hand, the author with easy to understand the language and a large number of illustrations so that we can easily know why, on the other hand, I have always been interested in network programming and the content of this book has a great fit point, Today's content is also related to their own interest in the HTTP protocol on the TCP part, is from the book fourth-"Connection management" part of the content summarized.

What network latency does the HTTP request process have?

  1. domain name resolution: Domain Name resolution is the first step in network access, Identify the domain name as a TCP-aware IP address. This step is often due to the quality of the domain name resolution service caused many problems, my actual engineering practice encountered the most common problem is the choice of domain Name Service provider quality is not good or the client itself set the domain name resolution service address error causes the domain name resolution slow or failure. However, there is now a small DNS cache for most HTTP clients to save the IP addresses of recently visited sites, which can effectively mitigate this problem.

  2. Next, the client sends a TCP connection request to the server, and waits for the server to echo a response. Each new TCP connection has a connection settling delay (typically up to two seconds), and for a single-threaded browser, it is conceivable that the time stack value will be large if there are hundreds of concurrent HTTP transactions.

  3. Once the connection is established, the client and server end up sending and receiving requests via this established TCP pipeline, which depends on the hardware speed, network and server load, the size of the request and response message, and the distance between the client and the server. See my article, "Considerations for building high-performance services."

TCP Correlation Delay
  • TCP Connection build handshake


    When a new TCP connection is established, A series of IP groupings is exchanged between the two ends of the TCP, and if the connection is only used to transfer a small amount of data, the process of establishing a connection can greatly affect the performance of HTTP.

    Normally HTTP transactions do not exchange too much data, syn/syn+ An ACK of two times the handshake produces a measurable delay, but the third handshake--tcp the connection ACK packet is usually large enough to host the entire HTTP request message (The modern TCP stack allows the client to send data in this acknowledgment packet), and many HTTP server response messages can be placed in an IP packet.

    As you can see, small HTTP transactions can take up to 50% on TCP connections More time. So we often have the need to reuse HTTP connections in reality.

  • tcp delay acknowledgement mechanism

    But HTTP has a Shuangfeng feature of the request-the response behavior reduces the possibility of the piggyback information. When you want to return the group in the opposite direction, it is not so much. In general, the delay acknowledgement algorithm introduces a considerable delay, so we should adjust or disable the delay acknowledgement algorithm based on the corresponding operating system.

note: Before modifying any parameters of the TCP protocol stack, Be sure to have a clear understanding of what you do. The purpose of introducing these algorithms in TCP is to prevent poorly designed applications from damaging the network. So after modifying these configurations, you should ensure that the application does not raise the problems that these algorithms avoid.

  • tcp slow start (congestion control)

    Because of this congestion control feature, So the transfer speed of the new connection will be slower than the connection that has been exchanged for a certain amount of data. This also requires us to consider improving transmission performance from the perspective of reusing HTTP connections (persistent connections).

  • nagle algorithm and Tcp_nodelay

    The Nagle algorithm raises several HTTP performance issues. For example, a small HTTP message may not fill a packet, so the cache waits, or waits for a confirmation packet to arrive (confirming that the packet latency is approximately 100-200 milliseconds).

    So HTTP applications often set the parameter Tcp_nodelay in their own protocol stack, disabling the Nagle algorithm to improve performance.

  • time_wait accumulation and port exhaustion
    for an explanation of time_wait status See my blog post Network programming: How does the time_wait state of TCP affect server development? " Before the time_wait time set to 2 is because the early router processing speed is relatively slow, But now the use of high-speed routers has greatly weakened the problem, so for the Web server can be set by the operating system to reduce the duration of the time_wait state, otherwise if the server has a large number of time_wait state can significantly affect server performance . As for port exhaustion, there are problems that can occur when benchmarking a Web server against a small number of client hosts, related to the TCP connection four-tuple.

Reference books:

"HTTP authoritative guide"

The effect of delay-tcp on HTTP transactions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.