Presumably, the company’s website, in order to accelerate the speed and stability of user access to network resources to improve user experience, reduce the source server access pressure, are using CDN cache. So what is CDN, what is the principle, today to everyone to popularize. If you are not familiar with DNS, you can take a look at this article “Front-end Network Basics” DNS must know must know.

What is the CDN

The full name of CDN is Content Delivery Network. Its purpose is to add a new layer of CACHE(CACHE) layer in the existing Internet, the content of the website will be published to the nearest user’s network “edge” node, users can get the content needed nearby, improve the response speed of users to visit the website. From the technical comprehensive solution because of the network bandwidth is small, the user visit is large, the network distribution is not equal, improve the user access to the website response speed.

How CDN works

The DNS resolution process should be known to all of you. Here is a review, and you can also check out this article “Front-end Network Basics” DNS must Know must know.

When a user enters in the address bar, the DNS resolution process is as follows:

  1. The browser checks whether the IP address corresponding to the resolved domain name exists in the cache. If yes, the resolution is complete. The TTL property can also be used to set the cache time of the domain name.
  2. If not in the browser cache, the browser checks the operating system cache to see if the corresponding parsed result exists (we assume there is no result in the cache and proceed).
  3. Request the local domain name server (LDNS) to resolve the domain name, using a recursive query (assuming there is still no hit).
  4. If the LDNS still does not hit, a resolution request is made to the root DNS server, followed by iterative queries.
  5. The root DNS server returns the TOP-LEVEL DNS IP address that the LDNS should query next time.
  6. LDNS queries the TOP-LEVEL domain name server. The TOP-LEVEL domain name server returns the IP address of the domain name server that should be queried next time.
  7. LDNS queries the domain name server, and the domain name server returns the queried target host IP address.
  8. LDNS returns the final IP address to the user’s host and writes it to the cache for future query.

There is a problem with this DNS resolution:

As the number of Internet users increases, the network access path is too long, which seriously affects the access quality of users. In particular, if the link between users and websites is congested by sudden heavy traffic, the access quality is unstable and the response speed is slow in areas where the number of remote Internet users is rapidly increasing.

CDN was created to solve this problem:

By adding a new layer of CACHE(CACHE) to the existing Internet, the content of the website is published to the node closest to the user’s network “edge”, so that the user can get the required content nearby, and improve the response speed of the user to visit the website. Basic principle is widely used in a variety of cache server, the cache server distribution to the user access relatively concentrated area or in the network, when users visit the web site, using the global load technology to the user’s access point to the nearest work cache server, directly by the cache server response to user requests.

  • After using CDN cache, the website access process becomes like this, as shown in the figure below:

  1. A user enters a domain name, and the operating system queries the IP address of the domain name from the local domain name server (LDNS).
  2. LDNS Authorization server to query domain names from ROOT DNS (assuming LDNS cache expires)
  3. The ROOT DNS replies the domain name authorization DNS record to the LDNS
  4. After obtaining the authorized DNS record of the domain name, the LDNS queries the IP address of the domain name from the authorized DNS
  5. Domain name Authorization DNS queries domain name recordsCNAME), reply to LDNS
  6. After obtaining the domain name record, the LDNS queries the IP address of the domain name from the Intelligent scheduling DNS
  7. Intelligent scheduling DNS responds the most suitable CDN node IP address to LDNS based on certain algorithms and policies (such as static topology and capacity)
  8. LDNS will get the domain name IP address back to the client
  9. After obtaining the domain name IP address, the user accesses the site server
  10. The CDN node server responds to the request and returns the content to the client (the cache server saves the data locally for future use on the one hand and returns the obtained data to the client on the other hand to complete the data service process).

CNAME is an alias (Canonical Name); This function is used to resolve A domain name to another domain name. When the DNS queries the name on the left of the CNAME, it turns to the name on the right of the CNAME to trace the last PTR or A name. The DNS responds only after the query succeeds.

For example, if you have a server with a lot of data, and you use to access those resources, but want to access those resources through, you can add a CNAME record to your DNS resolver. After pointing to and adding this CNAME record, all requests to access are forwarded to for the same content.

The function of CDN

To sum up, CDN has the following main functions:

  1. It saves backbone network bandwidth and reduces bandwidth demand
  2. Provide server-side acceleration to solve the server overload problem caused by the large number of user visits;
  3. Service providers can use Web Cache technology to Cache the Web pages and objects that users have visited locally, so that the access of the same objects does not need to occupy the bandwidth of the exit of the trunk, and improve the demand of the corresponding time for users to visit Internet pages.
  4. Can overcome the problem of uneven distribution of websites, and can reduce the cost of website construction and maintenance;
  5. Reduces the impact of communication storms and improves network access stability.

The resources

  • CDN acceleration principle
  • “Front-end network foundation” DNS must know and must know