In-depth web request process

      With the development of the network, the network of the Internet has been transformed from the traditional C/S architecture to a more convenient and fast B/S architecture.

  First, the benefits of B/S architecture:

(1) The client uses a unified browser.

(2) The server is based on unified HTTP, and the use of unified HTTP also simplifies the development mode for service providers, so that server developers can adopt a relatively standardized development mode.

2. Overview of B/S network architecture

        The B/S network architecture has been simplified from the front end to the back end, and is based on the unified application layer protocol http to exchange data. Short connection, and can serve more users at the same time.

         When the user enters a URL in the browser, the actions that take place are:

(1) DNS resolves the requested domain name to the corresponding IP address;

(2) Find the corresponding server according to this IP address;

(3) Initiate a request to the server, and then the server returns the corresponding data;

Note: There is still a lot of business logic on the server side: there may be many servers, and which server handles requests, which requires a load balancing device to evenly distribute requests from all users; and the requested data is stored in distributed The cache is still in a static file, or in the database; when the request is returned to the browser, the browser will parse the data and find that there are some static resources and initiate another http request, which is likely to occur on the CDN. , and then the CDN handles the request.

3. How to initiate a request:

      The process of initiating an http request is actually the process of establishing a Socket;

      Before the browser establishes the Socket, it must resolve the IP address according to the domain name of the URL entered in the address bar, and then establish a Socket connection with the remote server according to the IP address and the default port 80, and then the browser assembles a get type according to the URL. The http request header is sent to the target server through outputStream.write, the server waits for inputStream.read to return data, and finally disconnects the connection.

The core of the B/S network architecture is HTTP.

Fourth, DNS domain name resolution

(1) The browser will check whether there is a parsed IP address corresponding to the domain name in the cache. If so, the parsing process ends; the browser cache size and time are limited, and the time limit for the domain name to be cached can be determined by the TTL attribute. limit.

(2) The operating system will have a domain name resolution process, which can be set in WIndows through the C:\Windows\System32\drivers\etc\hosts file, which can resolve any domain name to any accessible IP address

流程:Local DNS Server ——>gTLD——>Name Server

(3) Domain name resolution records are mainly divided into A records, MX records, CNAME records, NS records, and TXT records

          #A records can resolve multiple domain names to one IP address, but cannot resolve one domain name to multiple IP addresses

5. CDN working mechanism

CDN, also known as content distribution network, is an advanced traffic distribution network built on the Internet.

CDN = mirror + cache + overall load balancing

CDN is scalable, secure, reliable, responsive and enforceable

CDN Architecture
Six, Load Balancing

       Load balancing is to balance work tasks and distribute them to multiple operation units for execution, and multiple servers cooperate to complete tasks together.

       The load balancing architecture is generally: link load balancing, cluster load balancing and operating system load balancing;

        Load balancing is done by DNS resolution. The advantage of this DNS resolution is that users will directly access the target server without going through other servers, and the access speed will usually be faster; the disadvantage is: DNS is in the user's local and Local DNS Servers have caches. Once a Web Server hangs, it is difficult to update the user's domain name resolution structure in time.

 

Cluster load balancing includes hardware load balancing and software load balancing.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326483624&siteId=291194637