The services you probably use every day, from Taobao to WeChat to Douyin, rely on something called a CDN, or Content Delivery Network. So what are these special computer networks for, and why are they so important?
1. What is a CDN?
The full name of CDN is Content Delivery Network, translated into Chinese is Content Delivery Network. CDN relies on the edge servers deployed in various places, and through the load balancing, content distribution, scheduling and other functional modules of the central platform, users can obtain content nearby, reduce network delay, and increase access speed. Simply put, CDN is used for acceleration, which allows users to obtain the required data faster.
For example, the server of a certain website is in Beijing. If a user in Shenzhen wants to obtain data on the server, it needs to travel a long distance. Due to factors such as transmission speed and routing and forwarding, the access speed will be very slow. If you try to visit a website on the other side of the world, it will take longer to load than a website hosted in your city or country. The farther packets have to travel, the more likely they are to bottleneck as they travel through the interconnect, or they may be lost. In this case, they must be sent again. But if we set up a CDN server in Shenzhen, and some server data is cached on it, then Shenzhen users only need to visit this CND server to obtain relevant content, which greatly improves the speed.
2. What is DNS?
To understand CDN, you must first understand DNS. We all know that when we enter a domain name in the browser, we can visit the site corresponding to the domain name. But the logic of the actual system operation is far more complicated than what we see, because the computer cannot directly recognize the domain name, so it must rely on some link to translate the domain name into an IP address, and this link is DNS.
When we initiate a request to the DNS server to resolve a domain name, the DNS server will first check whether the domain name exists in its own cache, and if the domain name exists in the cache, it can directly return the IP address. If there is no cache, the server will recursively access layer by layer.
For example, if we want to visit www.baidu.com, first we will first initiate a request to 13 root servers around the world to ask for the address of the com domain name, and then send a request to the name server responsible for the com domain name to find baidu.com, and so on. Recursively, finally find the IP address we need.
3. The difference between CDN and DNS
We mentioned above that the CDN actually provides a nearby access function, but now there is a problem, how do we get to the user’s location and allocate the best CDN node for it, which requires the use of DNS services for positioning.
When we use the DNS service, we can locate it according to the recursive server used by the user. But if you show us that the user is using a recursive server in Shenzhen, then it is considered that the user is from Shenzhen, and then the scheduling server will let the customer access the CDN server in Shenzhen.
However, there may be a problem with this scheduling method, that is, the user’s actual IP is not consistent with the recursive server. For example, I am a user of Beijing Unicom but use Shenzhen Telecom’s recursive server, then the scheduling server will allocate Shenzhen Telecom’s CDN server for me, which will cause wrong scheduling.
4. HTTP Scheduling
In response to the above problems, we have another scheduling method – HTTP scheduling.
When a user accesses the server, first analyze the user’s IP address, and then the server returns a 302 redirection to the user, storing the server closest to the user in the cache, and the user can get the best CDN node when requesting again.
This method is more accurate in positioning, but the disadvantage is that an additional HTTP access is required, which leads to a relatively high delay for the first access.
Therefore, in the actual situation, most of the two methods are combined, firstly through the DNS method to locate, and then through the HTTP method to correct the deviation.
5、Two ways of caching
Some resources on the server are cached in the CDN node. So how does the server update the cache of the CDN node?
The first way is that the server actively updates the cache, and the CDN node passively accepts and updates it. The second way is that when it is found that the resource requested by the user does not exist, the CDN node actively updates the cache, and then returns the data to the user. In terms of actual implementation, the second caching method is mostly used now, because there are many problems in the first method, and it is easier to generate 404.
6. CDN workflow
When a user requests a file, the CDN works as follows:
- DNS requests local local DNS
- The local local DNS recursively queries the gslb of the server
- The server assigns the best node according to local DNS and returns the IP
- Users get the best access IP and access the best node
- Suppose you are the first person in your area to request a specific file from the website, and this node does not have the content that the user wants to get, the system will access the previous node through internal routing until the file is found or the source site is reached and will The corresponding content is copied to the local cache.
- The local node of the CDN node will keep the copy in case other local users also need the file, and the data can be returned directly when other users request the file next time. If no one wants the file after a set time, it may be deleted until someone wants it again. In this way, the long-distance bandwidth is only used once, and then only the local bandwidth is used.
7、the benefits of CDN to the company
A CDN is more than just providing a good experience for users. They can save content providers money by preventing excessive use of expensive international bandwidth. CDNs can also accommodate large numbers of users, spreading the load across the network to ensure there is no denial of service. This also means that the CDN can provide protection against intentional Distributed Denial of Service ( DDoS ) attacks.
Additionally, CDNs provide a way to restrict content to content-permissible areas. This can be as simple as limiting locally hosted content to what is licensed in that region.
8. Can Anyone Use a CDN?
It is not just large companies that build their own server networks that can take advantage of CDN technology. Most CDNs are professional companies that provide hosting services and use CDN services as part of the hosting fee.
Individual users can benefit from CDN technology by using products from companies that rely on them. If you are a commercial user, you can also contact the CDN provider directly. Huosanyun integrated CDN integrates several top CDN manufacturers in the world. It is one of the very few integrated CDN platforms in China that truly realizes real-time monitoring, intelligent positioning analysis and intelligent scheduling decision-making. It is also the first domestic enterprise that has officially implemented global integrated CDN acceleration services. Fire Umbrella Cloud Fusion CDN is a fusion management service that further optimizes data network acceleration based on traditional CDN. In addition to serving audio and video on demand, file, application and Web acceleration, and various value-added scenarios, Huosanyun Fusion CDN also guarantees the quality of user services through comprehensive CDN quality monitoring and intelligent and easy-to-use acceleration node scheduling. Continuity, providing stable and fast network access quality.