Understanding web request process

1, a http request did what?

    When the browser user input www.baidu.com this url, it will ask DNS to resolve the domain name into the corresponding IP address, find the corresponding server based on IP address. May have more than one server, you need load balancing equipment to the average user requests; requested data is distributed cache or a static file store, or in a database; when the data back to the browser, the browser parses the data found there some static resources, at this time will initiate additional http request, the request may be on the CDN, CDN server then processes the request, generally involves these operations.

2, how to initiate a http request?

    To establish a socket connection are not very different. By outputstream.write write binary byte data format to comply with http. Browser before establishing the socket connection, the remote connection and port ip according to the remote server, and then assembling the browser into a url type http get request header to the target server via OutputStream.write, the server waits for return data inputstream.read , then disconnect.

  Here paste code. You can use basic httpClient initiated, there are linux in the curl command.

3, the common understanding http request header, response header, status code

    The FireFox Firebug and HttpFox, Chrome comes

4, DNS name resolution process

   (1) Enter the domain name address, the browser will first check the cache has no ip address and the corresponding domain name. There, the resolution process ends. (TTL property may be provided buffer time domain)

   (2) to find out whether there is a cache operating systems, hosts file can be set. There, the resolution process ends.

   (3) network configuration will be the DNS server address, the operating system will send the domain name to the DNS address provided herein, i.e., the region name server LDNS. (80% of domain name resolution to this end.)

          Command: windows available ipconfig linux available cat, etc / resolv.conf

   (4) LDNS failed to RootServer domain name server will request resolution. Root name server returns a primary domain name server address (gTLD international top-level domain name server)

   (5) LDNS server sends a request again gTLD

   (6) gTLD domain name server returns NameServer server (domain name server that is registered with the domain name provider) corresponding domain name.

   (7) NameServer -IP domain name server returns the mapping relationship, together with the TTL value is returned to LDNS. Finally, the analysis results to the user.

         Command: Tracking domain name resolution process A, nslookup (windows linux available) B, dig www.baidu.com C, can be used to resolve domain names InetAddress class.

5, CDN mechanism

     (1) describes the concept: is an advanced flow distribution network by adding a new layer of network architecture in the existing internet to publish content to the network edge closest to the user, allowing users to the nearest access to information, improve site response speed. Analogy: CDN = + buffer + mirroring the overall load balancing, because the flow of information may increase the efficiency of the network significantly. At present, the site is cached static data.

    (2) Scene Description: users access files through a static domain name cdn.image.com, first through LDNS, through iterative resolution, will be to resolve the domain name registration server. This time DNS server will usually resolve it back CNAME to another domain name, the domain name will eventually be directed to CDN global load balancing of DNS servers, then to assign the final GTM fastest access node, and returned to the user. If the node does not have the corresponding file, it is necessary to find the source station, and back again.

6, load balancing

   Usually there are three kinds of load balancing architecture: link load balancing, cluster load balancing, operating system load balancing.

7, CDN dynamic acceleration

 

    

  

Guess you like

Origin www.cnblogs.com/xudan/p/12064741.html