CDN Network Acceleration Principle

2021.07.31

The full name of CDN is Content Delivery Network, that is, content delivery network. The purpose is to add a new network architecture to the existing Internet and publish the content of the website to the network "edge" closest to the user, so that users can obtain the desired content nearby and improve the response speed of users visiting the website.


This article is reproduced from the WeChat public account "Programmer Xiaofan", author Fan Mili. To reprint this article, please contact the programmer's Xiaofan public account.

CDN

The full name of CDN is Content Delivery Network, that is, content delivery network. The purpose is to add a new network architecture to the existing Internet and publish the content of the website to the network "edge" closest to the user, so that users can obtain the desired content nearby and improve the response speed of users visiting the website. CDN is different from mirroring because it is smarter than mirroring, or you can make a metaphor: CDN = smarter mirroring + caching + traffic diversion. Therefore, CDN can significantly improve the efficiency of information flow in the Internet network. Technically, it solves the problems of small network bandwidth, large user visits, uneven distribution of outlets, etc., and improves the response speed of users visiting the website. Below is a simple CND diagram


As shown in the figure above, it is a schematic diagram of a common CDN architecture. Its workflow can be summarized as follows: When a user visits a website that has joined the CDN service, first use DNS redirection technology to determine the best CDN node closest to the user, and at the same time, the user The request points to this node. When the user's request arrives at the designated node, the CDN server (the cache on the node) is responsible for providing the content requested by the user to the user. The specific process is: the user enters the domain name of the website to be visited in his browser, the browser requests the local DNS to resolve the domain name, the local DNS sends the request to the main DNS of the website, and the main DNS is determined according to a series of policies The most appropriate CDN node at that time, and the result of the analysis (IP address) is sent to the user, and the user requests the content of the corresponding website from the given CDN node

Working Principle

The CDN network adds a Cache layer between the user and the server, which is mainly achieved by taking over the DNS and directing the user's request to the Cache to obtain the data of the source server, thereby reducing the network access time.

Access Process Without Cache Service

First, let's take a look at the access process of the traditional uncached service:


As can be seen from the figure, the traditional network access process is as follows:

1: The user enters the domain name to be accessed, and the operating system queries LocalDns for the ip address of the domain name; 2: LocalDns queries the ROOT DNS for the authorization server of the domain name (here assumes that the LocalDns cache expires); 3: ROOT DNS responds to the LocalDns with the domain name authorization dns record; 4: After LocalDns obtains the authorized dns record of the domain name, it will continue to query the ip address of the domain name from the authorized dns of the domain name; 5: domain authorized dns will respond to LocalDns after querying the domain name record; 6: LocalDns will respond to the client with the obtained domain name ip address ;7: After the user gets the domain name ip address, he visits the site server; 8: the site server responds to the request and returns the content to the client.

Access process of the website after using CDN cache


As shown in the figure above, it is the network access process after using CDN caching:

 1: The user enters the domain name to be accessed, and the operating system queries LocalDns for the ip address of the domain name;

 2: LocalDns queries the ROOT DNS for the authorized server of the domain name (here we assume that the LocalDns cache expires);

 3: ROOT DNS responds to LocalDns with the domain name authorization dns record;

 4: After LocalDns obtains the authorized dns record of the domain name, it continues to query the ip address of the domain name from the authorized dns of the domain name;

 5: After the domain name authorized dns queries the domain name record (usually CNAME), it responds to LocalDns;

 6: After LocalDns gets the domain name record, it queries the smart dispatch DNS for the ip address of the domain name;

 7: Intelligent scheduling DNS responds to LocalDns with the most suitable CDN node ip address according to certain algorithms and strategies (such as static topology, capacity, etc.);

 8: LocalDns will respond to the client with the obtained domain name ip address;

 9: After the user gets the domain name ip address, he visits the site server. In the case above, the CDN network adds a Cache layer between the user and the server, which is mainly achieved by taking over the DNS, and directing the user's request to the Cache to obtain the data of the source server, thereby reducing the speed of network access.