tags: Http network and DNS domain name resolution highlights
One: Initiate http:
There is no difference between initiating an http request and how to establish a socket connection. Before establishing a socket connection, the browser must parse the ip address according to the url domain name DNS entered in the address bar, and then establish a socket with the remote server according to the ip address and the default port 80. Connect, then the browser assembles a http request header of type get according to this url, sends it to the target server through outputStream.write, the server waits for inputStream.read to return data, and finally disconnects.
Summary: The process of initiating an http request is the process of establishing a socket communication.
Two: parameters: request response:
Three: common http status code:
Four: DNS domain name resolution process:
The first step: the browser checks whether there is a parsed ip address corresponding to the domain name in the cache. If there is, the parsing process ends, the browser cache domain name is limited, the cache size is limited, and the time is limited. Usually, it is a few minutes. The time limit can be set in a few hours. The cache time limit can be set by the TTL attribute. The cache time is too long. Once the ip changes to the domain name, the domain name cached by the client cannot be resolved to the changed IP address. It can't be parsed normally. During this time, some users may not be able to access the website. If the time is set too short, the user will have to re-parse the domain name every time they visit the website.
Step 2: If the user's browser cache is not available, the browser will look for the DNS resolution result corresponding to the domain name in the operating system cache. In fact, the operating system will also have a process of domain name resolution, through the c drive
Any domain name can be resolved to any ip address that can be accessed. If you specify the ip address of a domain name here, the browser will use the ip address first.
Note: Because of this DNS resolution procedure, it is possible for a hacker to resolve a particular domain name to its ip address by modifying your domain name resolution, causing the domain name to be hijacked.
The third step: How do you know the domain name server? In our network configuration, there will be a "DNS server address", which is used to solve the first two steps that cannot be solved. The system will send this domain name to the LDNS set here, which is the domain name server in the region. This DNS usually provides you with a DNS resolution service for local Internet access. For example, if you are accessing the Internet at school, then your DNS server must be in your school. If you are accessing the Internet in a community, then this DNS is the application provider that provides you with access to the Internet, namely Telecom or China Unicom, also known as SPA. Then this DNS is usually in a certain corner of the city, not very far, under Windows. Query this address via ipconfig,
The performance of this special domain name resolution server will be very good. They generally cache the domain name resolution result. The cache time is controlled by the domain name's expiration time. Generally, the cache space is not the main factor affecting the domain name invalidation. About 80% of the domain name resolution has been completed here, so LDNS mainly undertakes the domain name resolution work.
Step 4: If LDNS still does not hit, go directly to the Root Server domain name server to request resolution.
Step 5: The root domain name server returns the address of the primary domain name server (gTLD Server) of the domain to which the local domain name server is queried. The gTLD is an international top-level domain name server, such as .com, .cn, .org, etc., only about 13 in the world.
Step 6: The local DNS server sends a request to the gTLD server returned in the previous step.
Step 7: Accept the requested gTLD server to find and return the address of the Name Server domain name server corresponding to the domain name. The Name Srver is usually the domain name server you registered. For example, if you apply for a domain name from a domain name server provider, then the domain name is The resolution task is done by the server of this domain name provider.
Step 8: The Name Server domain name server queries the mapping relationship between the stored domain name and the ip. Normally, the target ip record is obtained according to the domain name, and a TTL value is returned to the DNS server name server.
Step 9: Return the ip and TTL values corresponding to the domain name. The Local DNS Server caches the correspondence between the domain name and the ip. The cache time is controlled by the TTL value.
Step 10: The result of the parsing is returned to the user, and the user is cached in the local system cache according to the TTL value, and the domain name resolution process ends.
Five: Clear the cached domain name:
This can make some abnormal dns parsing work normally.
Five: CDN working mechanism
CDN is a content distribution network (Content Delivery NetWork), which is an advanced traffic distribution network built on the existing internet. The purpose is to release the content of the website by adding a new layer of network architecture to the existing Internet. To the "edge" of the network closest to the user, the user can get the desired content nearby and improve the response speed of the user to the website. Cdn = mirror + cache + overall load balancing (gslb).
Currently, cdn is mainly used to cache static data in websites, such as css, js, images, and static pages. The user downloads the static data from the cdn after requesting the dynamic content from the primary server, thereby speeding up the downloading of the data content of the webpage.
Parsing: The user accesses a static file (such as a css file). If the domain name of the static file is cdn.taobao.com, then the request must first be sent to the Local DNS server. After iteratively parsing, return to the registration server of the domain name. Parsing, generally each company has a DNS resolution server, then the dns resolution server will usually re-rename it to another domain name, and the domain name will eventually be pointed to the DNS load balancing server in the CDN global, and then Gtm to finally allocate the location of the access user, return to the cdn node closest to this user.
After getting the dns parsing result, the user directly goes to the cdn node to access the static file. If the requested file does not exist in this node, it will go back to the source station to get the file and then return it to the user.
Six: load balancing:
Load balancing is to balance work tasks and distribute them to multiple operating units, such as image servers and application servers.
table of Contents 1. The basic introduction of HTTP 2. Features of HTTP 3. Know the URL 3.1 URL 3.2 The difference between URI and URL 4. HTTP protocol 4.1 Request message 4.1.1 Attributes in t...
The characteristics of the http protocol The HTTP protocol is an application layer protocol built on the TCP/IP protocol. The default port is 80/8080 The characteristic of the HTTP protocol is that th...
Foreword This article was written by me after reading "Illustrated http" and reviewing the knowledge about ajax. Mainly called telling simple http knowledge, how to operate js. , About CORS ...
HTTP Introduction: The HTTP protocol is an abbreviation of Hyper Text Transfer Protocol, which is a transfer protocol for transmitting hypertext from a World Wide Web (WWW: World Wide Web) server to a...
Recently I am reviewing related knowledge about HTTP, and I will continue to write related basic knowledge points later, which is also regarded as re-learning and consolidating. Come on! What is HTTP?...
Relearn http requests. Search for all kinds of information. Find a very good blog. I almost understood it almost after reading it. Of course, there are still some places to follow up. First mark the s...
The TCP protocol corresponds to the transport layer, and the HTTP protocol corresponds to the application layer. In essence, the two are not comparable. The Http protocol is based on the TCP protocol....
Code type Function type 2. Structure type 3. Interface type 4. Method Type 5. Custom type 2. Several important functions 3. Several important structures 4. Several important interfaces 5. Several impo...
HTTP protocol - Simple understanding TCP / IP protocol University did not read computer science, so a lot of expertise do not know. Now that you have engaged in IT industry, we need to understand is b...
Interview tomorrow, requires familiarity with the HTTP protocol, regrets that the university did not study seriously. I found an easy-to-understand article on the Internet with a link address https://...