Linux must be the principle of input URL to see the page content principle

Source: Internet
Author: User
Tags ack domain name server top level domain

users from the browser input URL to the page display, broken down basically by eight fast principle composition, they are:
DNS parsing principle, TCP three connections, HTTP request packets, packet encapsulation, packet unpacking, a request within the cluster, response packets from the server, four disconnects
> DNS parsing principle:
when the user enters the URL on the client, the client accesses the local HOSTS file and the DNS cache first, and our hosts are usually configured for testing. So the first access to the device, the local hosts and locals do not have this resolution, this time will be to Ldns (also to the local DNS to seek resolution), if Ldns here have records, will be feedback to the client, if Ldns does not have this record, Ldns will be to the global 13 root servers to parse. These 13 servers are "hierarchical" domain name resolution system, the topmost server is called root server, in the back of our website will be hidden behind. This point is the root server, the root server under the 13 servers called the first-level domain is also called the top level domain, and the following is a two-level domain, when the root server received the request, the root server only the following 13 top-level domain resolution, he will tell Ldns to access the corresponding first-level domain name server after the request, View your a record, tell Ldns to find Etiantian this server, Ldns find Etiantian server again, Etiantian server to view their A record, the information to inform Ldns. Ldns inform the client of the information. Both Ldns and local DNS will cache this record, also known as a record, with some records such as MX records for mail, PRT reverse parsing records, and CNAME records. A record is not one-to-one, he can be a couple. Here's a TTL (Time to live) that controls the DNS cache cycle, what is the TTL? Is the DNS how long to refresh, for the site to modify the amount of small can change the TTL time a little longer. For example, 3,600 seconds, so that the DNS cache for a long time, user access to data can be directly read from the local, speed up the traffic, if a URL modification is large, we will have to change the TTL time, if too large, the server has been modified, the local cache or the old. If too small is not good, if 1 seconds, DNS refreshes too fast, global DNS refresh to more than 12 hours, so users have been the same through recursion and iterative way to resolve to the back-end DNS resolution server brought a lot of pressure. DNS resolution is introduced everywhere. The client gets the IP address of the URL, and the following user is going to access the IP server.
> three-time Handshake for TCP
The client sends a SYN request to the server, and the state changes from closed to Syn_sent, and the server sends the SYN back to the client after receiving the client's SYN request, sending an ACK back, the server from the state to the SYN_RCVD State, After the client receives the SYN and the client returned by the server, returns an ACK to the service side, the client's state becomes establish, the server receives the ACK from the client and the state becomes established, and the connection to this TCP is established successfully
>http Request Message
Why should I connect to the HTTP protocol first?
The HTTP protocol is above the TCP protocol, so only the TCP connection establishes the later application layer's HTTP protocol to communicate ~~~~~~~~~~~~~~~~~~~~~~~
HTTP request message generally has a request line, request header, request the body three parts, in the request line contains the request method, URL and HTTP protocol version also has a blank line, they are separated by a space, now use the request method has Get.put,post,head, Delete,move. The Get method is to obtain the content from the server side by requesting the specified content from the client, and the Put method is to upload the client's resources to the server instead of the specified content, and the Post method submits the client's resources to the server, such as the registration form, delete and move infrequently, which is not described here. What does the request header look for? In the request header contains: Media type, language type, compression method, client information, host header, connection status, and other information, here and this request header related to the most common request header is Content-type media and content-length request length of both. Below the request header is a "blank line", where you can send a carriage return or newline to tell the blank line that there is no content for the request header. Below the empty line is the request body, if the Get method is not the request principal here. The request packets to this HTTP contain these things, and then go through the OSI seven layer model to start the data encapsulation for this request header
> Packet Encapsulation
the request packet encapsulates the data in the application layer, the TCP header is encapsulated on the transport layer to the data segment, the IP data segment in the Network layer encapsulation is converted into a packet, the data link layer is encapsulated into the Mac and the LLC header, the packet is converted into a frame, the following will be converted to a bit stream in the physical layer to transmit, Now that all of the client's work is over, the next bit stream will reach the remote LB load server, the load server extracts the data by unpacking, the process of encapsulation is just the reverse of the encapsulated packet, starting from the physical layer, to the application layer. After the application layer analyzes the information of the request message, the load will look for the specified content in the later content cluster, our common software load has the advantages and disadvantages of ' nginx LVS HAproxy ', and of course the load A10 and ′f5 of the hardware. If the requested information is static information, replication will request the rear of the static server, the company if there is a CDN, it will put these static files in front of the CDN, so that the customer access speed, but also to reduce the pressure on the internal cluster; If the request contains CSS,JSS and some are dynamic data, Because these structures of dynamic data are stored in the background of the database, or NFS, so will go to request the Database or NFS server, of course, the Database and NFS before the cache server like Mamcache, will directly access the cache, this is an internal optimization. The user wants the data through the internal cluster of a call, and finally to return to the client, here there is an HTTP response message
http contains: The starting line (also called the status line), the response header, the blank line, and the response body. The starting line contains the protocol and version, status code, and status information. The HTTP protocol has 0.9 1.0.1 and 1.1 now 0.9 has been eliminated. Compared to 1.0 and 1.1, the 1.0 version of the server and the client can only maintain a short connection, the request will close this connection, and 1.1 increase the keep-alive persistent connection, scalability, cache processing and other characteristics, persistent connection is also reflected in the request header, when the client's request header contains the close information, the request disconnects. The protocol version is followed by a status code of the number, the status code is feedback to the client information, to tell if the connection is successful, and the general direction of the fault, the status code range 100-199, specify the client should respond to the action, 200-299 the request is successful, and 300-399  400-499 Client error causes  500-599, server error, we often see a few code in the work, need attention, for example,:200  indicates the request succeeds,301  a permanent jump, but the request is successful,403  forbidden  Forbidden, here is generally the server one end of the permissions configuration problem,404 not found  This is also the server side, causing a lot of this reason, it is possible that the cluster internal data return timeout, or the requested content on the server no longer exists, 500 this is a content server general error, resulting in a lot of reasons, 502 bad gateway is generally the proxy server request backend, back end did not put back or request timeout, Generally the following node for the direction agent problem;503 services unavailable   Server is not available, either the server is overloaded or down, or the reverse proxy does not have a service node behind it  504  Gateway timeout  Agent back request, back end in a certain time without giving feedback, resulting in timeouts. Here's a look at the response header, which mainly contains, media type MIME, time, Server service version, connection status, character set type, MIME is a text tag, the middle is separated by a slash; below the response header is a blank line that tells the response header that the content ends, and the following is the response body, This loads the data to the client, which is either text or binary (image, video)
after the client receives the response message, sends a FIN signal to the server, the client changes from the established state to FIN_WAIT1, the server receives the client's fin and returns an ACK, and the server state changes to close_wait. The client receives the ACK that the server returns, the state becomes the fin_wait2, this time the client waits for the server, if the server has not sent the data, continues to send, if sends completes will send to the client a fin, at this time the server becomes Last_ack state, After the client receives the fin from the server, it immediately returns an ACK to the server informing the receipt that the status enters the time-wait, when the client enters the closed state after 2MSL time, and the server receives the client ACK and enters the closed state. To this four break end, there is another situation is the closing state, this is because the client sent fin to the server, without receiving the server's ACK but received the server's fin, the case of ACK drops, this may be the network cause ... This is the user from the browser to enter the URL to see the page content of a process

This article is from the "System World" blog, please be sure to keep this source http://sgk2011.blog.51cto.com/1551358/1794644

Linux must be the principle of input URL to see the page content principle

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.