This article will help you understand the technical principles of CDN!

This article will help you understand the technical principles of CDN!

Hello everyone, I am Brother Shu!

I believe everyone has heard of CDN. It feels strange but familiar. Recently, I learned more about CDN and found out how important it is! Today, I will share with you some things about CDN.

Browser network request

To understand CDN, we must first understand the process of a browser sending a request. The overall process is shown in the figure below.

Browser network request process

  • The user enters the domain name of the website to be visited in the browser.
  • The browser requests the local DNS server to resolve the domain name.
  • If the local DNS server has the resolution result of the domain name, it will directly respond to the user request and return the IP address corresponding to the domain name.
  • If the local DNS server does not have the resolution result for 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 the content from the server.
  • The server returns the content requested by the user to the browser.

After such a complex process, the user can see the page content. But in fact, in the 6th and 7th steps, there are also very complex processes in between. In order to express it more clearly, we can divide this process into 3 main nodes, as shown in the figure below.

Server data transmission process

The website server passes through the public network exit, then through the long-distance backbone network, and finally through the user's broadband modem to reach the user's local area network, and finally reaches the browser of the user's computer.

Among them, long-distance backbone network transmission is the most time-consuming. It needs to pass through the computer room where the website server is located, the backbone network, the metropolitan area network where the user is located, the access network where the user is located, etc., and its physical transmission distance is very far.

In this case, if the data transmitted is very large and the number of users accessing is particularly large, there will be a long delay, 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.

The scenario I just mentioned is very vividly illustrated by the Spring Festival ticket rush. When we rush to buy tickets during the Spring Festival, we will log on to the 12306 website, which must have a lot of picture resources. At this time, there may be 100 million people requesting the same picture at the same time.

At this time, if we follow the above process to request image data once, it will generate 100 million network data transmissions, which is a disaster for our entire country's Internet infrastructure!

But the fact is: 12306 doesn’t seem to be down!

So how do they solve this problem? The answer is: CDN!

What is CDN?

In fact, CDN means content distribution network, and its full name in English is Content Delivery Network. Simply put, CDN can store data in advance in the data node closest to the user, thereby avoiding long-distance travel through the long-distance backbone network, ultimately achieving the purpose of reducing the burden on the backbone network and increasing access speed.

According to the above scenario, if there is no CDN, each request needs to go from the website server to the public network exit, long-distance backbone network, user access LAN, and finally reach the browser. But with CDN, it may become as follows:

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, it will be returned directly. Otherwise, it will go through the long-distance backbone network and finally reach the website server to obtain the image data. As long as we upload the image to the CDN cache server in advance, we can greatly reduce network traffic and reduce network latency.

From the above picture, we may think: Isn't this just adding a server between the long-distance backbone network and the user's LAN? But in fact, this is not the case. CDN actually shortens the distance of requesting data.

We know that users may be located all over the country. In order to minimize the delay of network transmission, CDN cache servers are generally set up close to users. For example, a main CDN server is set up in South China, North China, East China, and Southwest China. In this way, users in various regions can directly request the corresponding CDN server without having to travel back and forth across most of China, which greatly improves efficiency!

Therefore, when we talk about content distribution network, we should have the following picture in mind: CDN cache servers spread all over the country form our content distribution network. Every time a user requests data, it will go to the CDN server closest to him to request data, thus greatly improving the access speed.

How CDN works

At this point, I believe everyone knows what CDN is. But how CDN is actually combined with DNS is still a bit complicated. After adding CDN, the browser's network request becomes as shown in the following figure.

Basic working process of CDN

  • The browser initiates a request for the image URL, and after local DNS resolution, the domain name resolution authority 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 user's area 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 (based on considerations including 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 that use 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 to achieve content acceleration!

Summarize

From this perspective, CDN content distribution network is essentially a bunch of cache servers spread all over the world. By cooperating with DNS, it finds a CDN cache server closest to the user and then distributes the data to the user quickly.

Through CDN technology, we not only reduced the traffic burden on the overall backbone network, but also improved the user experience. It really kills two birds with one stone!

<<:  Comparison and conversion between IF sampling and IQ sampling

>>:  What is 5G RedCap, and can it save cellular IoT?

Recommend

How Do PoE Switches Work?

All modern industrial equipment uses long cables ...

Introducing a request library - How to use several Undici APIs

[[430223]] Preface In the browser, if we want to ...

McKinsey: These ten trends are enough to subvert the existing IT infrastructure

When it comes to hardware and IT infrastructure, ...

One cannot miss the key points of future data center development

Where will the data center of the future go? I be...

Review of 5G in 2019: 5G sounded the rally call for commercial use

"5G is like a newborn baby, new from head to...

What are the characteristics of 5G? A few keywords will help you understand

5G (fifth-generation mobile communication technol...

Building a streaming data lake using Flink Hudi

This article introduces how Flink Hudi continuous...

Five disruptive features of 6G networks

The telecommunications industry is constantly pur...