How to understand the technical principles of CDN?
- Huawei Mate 60 Pro Makes Satellite Calls: Only US$0.18/minute
- Huawei Mate60 Pro: First Smart Phone Supports Satellite Calls
- 14000 cores + 450W: RTX 4080 graphics card perfectly replaces the RTX 3080
- Big upgrade: The difference between Bluetooth 5.0 and 5.2
- Geeks Disappointed that RTX 4080/4090 doesn’t come with PCIe 5.0
- What are advantages and disadvantages of different load balancing?
How to understand the technical principles of CDN?
The website server exits through the public network, then passes through the backbone network, and finally reaches the local area network where the user is located through the user’s broadband modem, and finally reaches the browser of the user’s computer.
We believe everyone has heard about CDN, and it feels both unfamiliar and familiar.
Recently, we took a deep look at CDN, and then realized that it is so important!
Let’s see what are important things about CDN.
Browser’s network request
To understand the matter of CDN, we must first understand how the browser makes a request.
The overall process is shown in the figure below.
Browser network request process
- The user enters the URL domain name to be accessed in the browser.
- The browser requests the resolution of the domain name from the local DNS server.
- If the local DNS server has the resolution result of the domain name, it directly responds to the user request and returns the IP address corresponding to the domain name.
- If the local DNS server does not have the resolution result of the domain name, it will recursively request the DNS system for resolution, and then return the result to the user.
- After the browser obtains the domain name resolution result, it is actually the IP address corresponding to the domain name.
- The browser then requests content from the server.
- The server returns the content requested by the user to the browser.
By such complicated steps, users can see the content of the page.
But in fact, in the 6th and 7th steps, there is a very complicated process in the middle.
For more clarity, we can divide this process into 3 main nodes, as shown in the figure below.
Server data transfer process
The website server exits through the public network, then passes through the long-distance backbone network, and finally reaches the local area network where the user is located through the user’s broadband modem, and finally reaches the browser of the user’s computer.
Among them, the transmission of the long-distance backbone network is the most time-consuming.
It needs to go through the computer room where the website server is located, the backbone network, the metropolitan area network where the user is located, and the access network where the user is located, etc. The physical transmission distance is very long.
In this case, if a large amount of data is transmitted and the number of users accessing is particularly large, a long delay will occur, affecting the user experience.
At the same time, each request for data requires a long data transmission, which is a burden for the long-distance backbone network.
So how did they solve this problem? The answer is: CDN!
What is CDN?
In fact, CDN means content distribution network, and its full English name is Content Delivery Network. Simply put, CDN can store data in the data node closest to the user in advance, so as to avoid long-distance travel through the long-distance backbone network, and finally achieve the purpose of reducing the burden on the backbone network and improving the access speed.
According to our above scenario, if there is no CDN, each request needs to go from the website server through the public network exit, the long-distance backbone network, the user’s access to the local area network, and finally to the browser. But when there is a CDN, it may become the following:
CDN cache server
When the browser requests image data, it will first go to the CDN cache server to obtain it.
If the data is obtained, then return directly.
Otherwise, it will go through the long-distance backbone network and finally reach the website server to obtain image data.
So as long as we upload images to the CDN cache server in advance, we can greatly reduce network traffic and reduce network latency.
From the above picture, we may think that this is not just adding a server between the long-distance backbone network and the user LAN.
But in fact, this is not the case. CDN actually shortens the distance of requesting data.
We know that the location of users may be all over the world.
In order to reduce the delay of network transmission as much as possible, CDN cache servers are generally set up in places closer to users.
CDN server, so that users in various regions can directly request the corresponding CDN server, without the need to let the request travel back and forth all over the world, which greatly improves the efficiency!
Therefore, when we say content distribution network, we should have this picture in mind: CDN cache servers all over the world make up our content distribution network.
Every user request will go to the nearest CDN server to request data, which greatly improves the access speed.
How does CDN work?
At this point, we believe everyone knows what a CDN is. But actually how CDN is combined with DNS is still a bit complicated.
fter joining the CDN, the browser’s network request becomes as shown in the following figure.
CDN basic working process
- The browser initiates a picture URL request, and after local DNS resolution, the domain name resolution right is handed over to the CDN dedicated DNS server pointed to by the domain name CNAME.
- The CDN’s DNS server returns the CDN’s global load balancing device IP address to the browser.
- The browser initiates a URL request to the CDN global load balancing device.
- The CDN global load balancing device selects a regional load balancing device in the region to which the user belongs based on the user’s IP address and the URL requested by the user, and initiates a request to it.
- The regional load balancing device will select the most suitable CDN cache server for the user (the basis for consideration includes: server load, distance from the user, etc.), and return it to the global load balancing device.
- The global load balancing device returns the selected CDN cache server IP address to the user.
- The user initiates a request to the CDN cache server, the cache server responds to the user request, and finally returns the content required by the user to the browser.
Websites using CDN services only need to hand over the domain name resolution rights to the CDN service provider, and then upload the content to be distributed to the CDN, and the content can be accelerated!
Looking at it this way, in fact, the CDN content distribution network is essentially a large number of cache servers located in every corner of the world.
hrough the cooperation with DNS, find a CDN cache server closest to the user, and then distribute the data to the user quickly.
Through CDN technology, we not only reduce the traffic burden on the overall backbone network, but also improve the user experience. It really kills two birds with one stone!
- DIY a PBX (Phone System) on Raspberry Pi
- How to host multiple websites on Raspberry Pi 3/4?
- A Free Intercom/Paging system with Raspberry pi and old Android phones
- DIY project: How to use Raspberry Pi to build DNS server?
- Raspberry Pi project : How to use Raspberry Pi to build git server?