This is the 14th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021
When it comes to CDN, it is certainly not a strange term for us front-end engineers. We all know that it is a system used to improve the speed of website access. However, when we go further, for example, what parts are it composed of and how to improve the speed of website access, we can’t give a good answer. Therefore, this article is ready to have a good chat about the specific content of CDN.
What is the CDN
Content Delivery Network (CDN) is a Content Delivery Network. Its functions can be clearly defined from its name: According to certain rules for intelligent distribution of network resources and content, its main idea is to avoid as far as possible on the Internet may affect the speed and stability of data transmission bottlenecks and links, so that the content transmission faster and more stable
CDN network consists of many nodes, the nodes cache on the targeted site static resource, most of the users get the static resources is also provided by the CDN node, rather than the source station, due to the CDN nodes usually close to the user in the physical distance, so resources transmission path, thus can greatly improve the response speed of the site
CDN nodes are usually divided into three categories:
- The central node has the CDN network management center and the global load balancing DNS redirection and resolution system, and is responsible for the distribution and management of the entire CDN
- Zone nodes, used to manage all edge nodes under an area, in order to relieve the pressure on the central node
- Edge node, the node closest to the user is usually alsodirectlyIf the node that provides static resources for users does not have corresponding resources, it conducts recursive search to the upper level. The search path is as follows: Edge node => area node => Central node => source stationLoad balancing equipment,Cache serverTwo parts
- Load balancing device: it balances the load of each Cache on each node to ensure the working efficiency of the node. In addition, it collects information about nodes and the surrounding environment and communicates with the GLOBAL DNS to implement load balancing of the entire system
- Cache server: Stores a large amount of information about a client’s web site and responds to local users’ access requests like a web server located close to the user
These three types of nodes form the so-called “three-tier deployment architecture”, as shown in the figure below
CDN workflow
Generally, the working process of CDN is as follows:
- The request is resolved by the local DNS server. If the resolution succeeds, the local DNS server returns the corresponding IP address to the user
- If the previous step fails, the resolution task is forwarded to the authorized DNS server, that is, the CDN dedicated DNS server pointed to by CNAME. In fact, this is the so-called load balancing DNS redirection resolution system
- The load balancing DNS redirection resolution system requests the optimal node IP address
- Returns the parsed IP address
- The user initiates a request to the node corresponding to the resolved IP address. The cache server responds to the request and sends the content required by the user to the user terminal. At this point, the whole process ends
The advantages of CDN
CDN has the following advantages:
- By eliminating the bottleneck of interconnection between different operators, the network is accelerated across operators. At the same time, by means of intelligent request allocation of DNS redirection resolution system of load balancing, the website performance can be improved to the greatest extent
- The widely distributed CDN nodes plus the intelligent redundancy mechanism between nodes can effectively prevent hacker intrusion and reduce the impact of various DDoS attacks on websites, ensuring the availability of websites to the greatest extent
- The widely distributed CDN nodes also ensure the ability of disaster resistance and recovery
- Due to mirror synchronization between servers, the entire process of resource update is completely automated, greatly reducing the maintenance cost
- It can help the source station reduce the pressure of requests and realize the effect of diversion
conclusion
Website, there are so many ways to optimize the CDN is certainly one of the important link, so it is very important to understand and master its principle, this article said is just the tip of the iceberg, many things still need to actual operation to understand, the so-called practice is the sole criterion for testing truth, so still have to continue to work hard to do ah ~