HTTP protocol Overview (1) non-persistent connections

Source: Internet
Author: User
    • The concept of "non-persistent connection"

A webpage consists of the most basic HTML and 10 Items JPEG Image structure,10 Items JPEG Image files are stored on the same server. SetThe URL isWww.server.com/somepath/index.html. If the user requests this webpage and uses"Non-persistent connection ",HTTPCustomer (usuallyThe following operations are performed between the user's browser and the server:

1. HTTP Initialize a client and a server hostWww.server.com In HTTP Server TCP Connection. Server uses default port 80 Listen from HTTP Customer's connection creation request.

2. HTTP Client TCP Associated local Socket Issue HTTP Request Message (Request). The message contains the path name. /Somepaht/index.html .

3. HTTP Server access and TCP Associated local Socket After receiving the request message, the file is retrieved from the memory or hard disk of the server host. /Somepath/index.html , Through the same Socket directionHTTPClient Send a response message containing the file (Response Message).

4. HTTP server notification TCP service layer disable TCP connection; the TCP Service Layer does not close the connection immediately, but the connection is terminated only after the customer receives the Response Message.

5. HTTP The client goes through the same Socket Receive this response message (Response Message). TCP The connection is subsequently terminated. The messages received by the client encapsulate Html File. The client browser extracts the file from it and analyzes it to find that there are 10 Items JPEG Object reference.

6.For each referencedJPEGRepeated object steps1~4.

 

The above steps are called non-persistent connections because each time the server sends an object TCP The connection is closed, that is, each connection does not last until other objects can be transmitted. Each TCP A connection can send only one request message and Response Message. In the preceding example, Web The page is generated 11 Items TCP Connection (one webpage request connection and 10 image request connections ).

 

In the above example, it is not clearly stated that the customer opens 10 Obtain each JPEG Object, or open multiple TCP Connect multiple JPEG Object. In fact, today's browsers allow users to control the degree of parallel connections through configuration. Most browsers can open 5 ~ 10 Parallel TCP Connection. Each connection processes one request. / Respond to the transaction. If you set the number of concurrent connections 1 In that case, the transfer JPEG Of 10 Connections are established in serial mode. Parallel connections can shorten the response time.


The time taken from the basic HTML file requested by the customer to the time it receives the file is the round-trip time (round trip time-RTT ). It is the time it takes for a small group to swim from the client to the server to return to the client. RTT includes packet transmission latency, packet queuing latency on intermediate routers and switches, and packet processing latency. Next we will consider what will happen when a user clicks a hyperlink. The user clicks, causing the browser to initiate a TCP connection to the Web server. The three-way handshake process is involved. First, the customer sends a small redundant message to the server, then the server confirms the message to the customer and responds with a small TCP Message. Finally, the customer delivers the confirmation to the server. The first two handshakes in the three-way handshake process end with an RTT. At this time, the customer sends the HTTP request message to the TCP connection. Then, the customer sends the last confirmation message of the third handshake process to the request data group. After receiving a request message from TCP, the server sends the corresponding HTML file to the TCP connection, the server then sends the confirmation token contained in the previous customer request message to the Data Group of the HTML file. This round of HTTP Request/response also took 1 RTT time. Therefore, the total response time is roughly two RTTs plus the time when the server sends the HTML file.
 

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.