It was about 7pm on Saturday night and I was reading a book when my girlfriend ran over and asked me where her IPAD had gone.

After she got the IPAD, she stopped talking to me, but as a programmer, I was still curious whether I could handle the traffic. Hahaha. So I looked and saw the following

However, the live broadcast did not seem to be too slow, could not help saying a paragraph:

It is understood that Ali Cloud provided Edge Node service (ENS) for Huya in January 2018. Based on Ali Cloud ENS, business modules can be easily placed on the edge of operation, and transcoding and distribution can be realized on the nearest node when the anchor pushes the stream. Meanwhile, edge distribution of high-concurrency real-time bullet screen is supported. In addition to low network delay, it reduces the pressure on the center and saves more than 30% of the center bandwidth cost. In addition, the network connection delay of edge nodes is less than 5 milliseconds, which improves the uplink quality of anchors and the percentage of successful connection of users, and effectively improves the user viewing experience. The most important technology in ENS is CDN.

The live broadcast finally ended, my girlfriend finally ran over to ask me what is CDN…

What is the CDN

The full name of CDN is Content Delivery Network.

We have all used Tmall supermarket, it is very convenient to buy things on it. The mode of Tmall supermarket is that goods are first entered into the rookie warehouse of Tmall Supermarket (hereinafter referred to as “Maochao”), and then uniformly delivered by Maochao.

In order to shorten the logistics time and enable consumers to receive goods quickly, Cainiao has built local warehouses all over the country. Now, in most cases, orders placed on Maochao can be received the next day (the owner of the building is in jiangsu, Zhejiang and Shanghai free delivery area, and there may be a little delay in other areas).

For example, WHEN I placed an order to buy a box of snacks in Xihu District of Hangzhou, it was not long before I could see that Maochao had been delivered. The delivery address was Xiaoshancang of Hangzhou. It was delivered from one district of Hangzhou to another district in 24 hours.

The distribution mode of Cat Super is intelligent warehouse. Cainiao provides tmall supermarket with intelligent warehouses across the country. Before the sale of goods, cainiao has come to the nearest storage base from consumers.

We can see cainiao’s warehouses across the country on its official website. We can see that cainiao currently covers 70 cities in 20 provinces across the country, with 327 warehouses in total. Together, these warehouses are called the national warehouse network.

Figure: Cainiao national warehouse distribution network

When we browse the network, in fact, it is very similar to the above process. When we visit a page, we will request a lot of network resources to the server, including all kinds of pictures, sounds, movies, text and other information. It’s the same as many of our purchases.

Just as Maochao stores goods in advance at local warehouses built by Cainiao around the country to reduce logistics time, the site can distribute content in advance to acceleration nodes around the country. In this way, users can access the content they need at the nearest location, avoiding access delays caused by network congestion, location, and carrier, effectively improving download speed, reducing response time, and providing a smooth user experience.

Therefore, the CONTENT distribution network, like the afore-mentioned National storage-distribution network, has solved the access delay problems caused by distribution, bandwidth and server performance, and is suitable for site acceleration, on demand and live broadcasting. Users can get the content nearby, solve the Internet network congestion, improve the response speed and success rate of users to visit the website.

After the warehouse distribution network, in addition to improving the efficiency of goods distribution, there are many other benefits:

1, first by anticipating the goods distribution, makes the final goods from the warehouse to consumers’ hands is relatively short, the process of the city within the scope of alternative distribution company will have many choices, in addition to the larger cross a, motion, also can choose a few small logistics company, and even novice direct call hungry hummingbirds distribution is not impossible.

CDN technology eliminates the influence caused by the bottleneck of interconnection between different operators, realizes the network acceleration across operators, and ensures that users in different networks can get good access quality

2, for the warehouse distribution system, the biggest disaster may be the warehouse fire, flood and other natural disasters. If the original centralized large warehouse is broken up into several distributed small warehouses, which are deployed in different areas, the impact of natural disasters can be effectively reduced.

The widely distributed CDN nodes and intelligent redundancy mechanism between nodes can effectively prevent hacker intrusion and reduce the impact of various DDoS attacks on websites, while ensuring better service quality

The basic working process of CDN

The distribution mode adopted by traditional express delivery enterprises is carried out through the link of “merchant → network → distribution → distribution → network → customer”. This process will have some problems, such as links, slow aging, easy to damage and so on.

The above process is similar to the traditional website request response process, which generally goes through the following steps:

  • The user enters the domain name of the web site to visit in his browser.

  • The browser requests the local DNS server to resolve the domain name.

  • If the resolution result of the domain name is cached on the local DNS server, the local DNS server responds to the resolution request directly.

  • If the local DNS server does not cache the resolution result of the domain name, it iteratively sends a resolution request to the entire DNS system and sends the result to the browser after receiving the response.

  • The browser obtains the domain name resolution result, which is the IP address of the service device corresponding to the domain name.

  • After obtaining the IP address, the browser establishes a TCP connection through the standard TCP handshake process.

  • The browser makes an HTTP request to the server.

  • The server sends the user’s request to the browser.

  • The TCP connection is disconnected after the standard TCP waving process.

After e-commerce self-established logistics, the distribution mode has changed: goods are prepared in advance and parts from different places are transformed into parts in the same city, which eliminates the time-effectiveness of the main link. High automatic sorting ensures fast delivery and low damage rate of sorting.

For users, the shopping process has not changed, the only feeling is that the logistics seems to be faster than before. Therefore, after the introduction of CDN, users generally go through the following steps to visit websites:

  • When a user clicks a URL on a website, the URL is resolved by the local DNS system. If the local DNS server does not have the corresponding domain name in cache, the local DNS system grants the domain name resolution right to the CDN dedicated DNS server pointed to by the CNAME.

  • The DNS server of the CDN returns the GLOBAL load balancing device IP address of the CDN to the user.

  • The user sends a URL access request to the global load balancing device of the CDN.

  • CDN The global LOAD balancing device selects a regional load balancing device of the region to which the user belongs based on the USER IP address and URL requested by the user and forwards the request to the device.

  • Based on the comprehensive analysis of the following conditions, the LLB selects an optimal cache server node, obtains the IP address of the cache server from the cache server node, and returns the obtained IP address to the global load balancer:

  • Determine which edge node is closest to the user based on the user IP address.

  • According to the content name carried in the URL requested by the user, judge which edge node has the content required by the user;

  • Query the current load of each edge node to determine which edge node has service capability.

  • The global load balancer returns the IP address of the server to the user.

  • The user sends a request to the cache server. The cache server responds to the request and sends the content required by the user to the user terminal. If the cache server does not have the content the user wants, and the zone balancer still allocates it to the user, the server requests the content from its upper-level cache server until the source server that traces it back to the web site pulls it locally.


Figure: Huawei cloud acceleration diagram

The CDN global load balancer and CDN regional load balancer resolve domain names into the IP addresses of cache servers on corresponding nodes based on user IP addresses. In this way, users can access the domain names nearby and the server responds quickly.

The composition of CDN

In the same way that a warehouse network is composed of multiple warehouses, a content delivery network (CDN) is composed of multiple nodes. Generally speaking, CDN network is mainly composed of central node and edge node.

Figure: Download acceleration scene of Dilian Cloud

Center node

The central node includes the CDN network management center and the global load balancing DNS redirection resolution system, which distributes and manages the entire CDN.

Edge node

CDN edge node mainly refers to the remote distribution node, which is composed of load balancing device and cache server.

The load balancing device 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.

A Cache is responsible for storing a large amount of information about a customer’s website, acting as a website server close to the user in response to local users’ requests for access. Through the control of global load balancing DNS, users’ requests are transparently directed to the nearest node, and the Cache server in the node responds to the end users’ requests just like the original server of the site. Its response time is faster because it is closer to the user.

The central node is like the master warehouse responsible for the distribution of goods in the warehouse distribution network, while the edge node is responsible for the storage of goods in each city’s local warehouses.

At present, many cloud vendors providing CDN services have deployed many CDN nodes in various places. Taking Ali Cloud as an example, we can learn from its official website that Ali Cloud has 2500+ nodes worldwide. The Chinese mainland has more than 2,000 nodes, covering 34 provincial-level regions, with a large number of nodes located in first-tier cities such as provincial capitals. Overseas and Hong Kong, Macao and Taiwan have more than 500 nodes covering more than 70 countries and regions.

Figure: Distribution of ALIyun CDN nodes in mainland China

Had pictured above ali cloud after mainland China CDN node distribution (this is also and we saw that warehouse network across the country, it is like to novice network), a telecommunications network in hangzhou users, access a deployment on ali cloud site, access to some resources, such as a picture on the page, a video or some words, The site may be pre-distributed to a mobile CDN storage node in Zhejiang, which can greatly reduce the response time of the site.

CDN related technology

First of all, we want to build a huge warehouse distribution network need to consider what problems, what technical means need?

The author thinks that there are four important points to pay attention to, which are as follows:

1. How to properly distribute the goods to the local warehouses in each city.

2. How to properly store goods in each local warehouse.

3, according to the user’s delivery address, intelligent matching should be given priority to which warehouse delivery, which logistics method to choose.

4. How to manage the whole warehouse distribution system, such as the accuracy of the overall distribution of goods, the timeliness of the warehouse distribution, the matching degree of the delivery place, etc.

Photo: Cainiao warehouse intelligent robots sorting goods

In fact, this happens to coincide with the four most important technologies in CDN, that is, content publishing, content storage, content routing and content management.

Content distribution

It uses indexing, caching, stream splitting, Multicast and other technologies to publish or deliver content to the nearest remote service point (POP).

Content store

For CDN system, two aspects of content storage need to be considered. One is the storage of the content source and the other is the storage of the content in the Cache node.

Content routing

It is a holistic network load balancing technology that balances user requests over multiple remote pops through the redirection (DNS) mechanism in the content router so that the user requests a response from the nearest content source.

Content management

Through internal and external monitoring systems, it obtains the health information of network components and measures the end-to-end performance of content publishing (such as packet loss, delay, average bandwidth, startup time, frame rate, etc.) to ensure the optimal running state of the network.

References:


https://www.gelonghui.com/p/140685

https://blog.csdn.net/championhengyi/article/details/80726304

https://www.gelonghui.com/p/140685