Alibaba Cloud CDN Accelerator Basic Concepts and Purchase and Activation

1. The basic concept of CDN accelerator

CDN accelerator official document: https://help.aliyun.com/product/27099.html

1.1. Basic introduction of CDN accelerator

The Content Delivery Network (CDN) is a distributed network that is established and covered on the bearer network and consists of servers in different regions. The source site resources are cached to edge servers across the country for users to obtain nearby, reducing the pressure on the source site.

CDN is equivalent to caching service. It is a distributed network composed of servers in different regions. The website data will be cached in CDN. When a user requests, it will first reach the CDN accelerator, and the CDN will distribute the user's request to the server in the area closest to the user. , to speed up the network of the website. When the data requested by the user does not exist in the CDN, the CDN will return to the source, and the CDN will request the data in the WEB server to prevent malicious users from frequently requesting website traffic.

The users of the system may be located all over the country. If the server of the program is in Beijing, then accessing our program from Tibet and Yunnan will be particularly slow compared to users in Beijing, Tianjin and Hebei. It is very likely that timeouts will occur, even if the website is optimized. No matter how good the system is, it is useless if users in remote areas cannot use the system normally.

In response to this phenomenon, the content distribution network CDN has been widely used. As long as it is a program in the Internet environment, almost all programs use a CDN accelerator.

CDN application scenarios:

  • image file
    • The static resources of the website, including pictures, etc., can be cached in the CDN to speed up user requests.
  • large file download
    • When large files are cached in the CDN, the user's download speed will be improved.
  • audio and video files
    • Most audio and video companies will cache the video in the CDN, and the speed will be very fast when the user plays the video.

1.2. The architecture diagram of the website introducing CDN accelerator

The CDN accelerator is introduced in the following website architecture.

When the CDN is not used, the user's request directly reaches the WEB server. After using the CDN accelerator, the user's request will first reach the edge server closest to the user. For example, the user in Shanghai, after the user in Shanghai requests the website, the traffic will be It is first processed by the CDN, and the CDN will distribute the user's request to the Shanghai edge server closest to the Shanghai user. At this time, the Shanghai user's access to the website will be greatly accelerated. Normally, it may take 5 seconds for the Shanghai user to access the WEB server in the Beijing computer room. After accessing the CDN, the user can directly obtain the data of the WEB program in the Beijing computer room in the edge server in Shanghai, which greatly speeds up the website access.

When there is no data required by the user in the CDN cache, the edge server will not directly request the WEB server, but the CDN will request our WEB server, then cache the data in the CDN, and then the edge server will read the latest from the CDN Data can also avoid crashing the website server due to a large number of requests.

It is also possible to directly push the data to the CDN from the WEB server, and the CDN sends it to each edge server to improve the hit rate of the data.

The request process of the website after using the CDN accelerator is as follows:

​ User—>CDN—>Edge server processing request

​ When the data requested by the user is not in the CDN: CDN—>WEB server

​ ↓

​ Edge Server—>CDN—>User

​ The CDN returns to the source WEB server, the WEB server is cached in the CDN, and the edge server reads new data from the CDN and returns it to the user

image-20220126174948692

From the figure above, it can be concluded that there are two ways for CDN to cache data:

  • The edge server returns to the source CDN accelerator, and the CDN accelerator obtains the latest data from the WEB server, and then caches it.
  • The WEB server pushes the cached data to the CDN, and the CDN accelerator pushes the cached data to each edge server.

1.3. Working principle of CDN accelerator

After the website is connected to the CDN, the domain name will be resolved by the DNS to the domain name provided by the CDN through CNAME. Therefore, before using the CDN, the method of the website must be a domain name and can be resolved into an IP.

1) When a user requests www.aliyundoc.com website resources, the local DNS first resolves the website to the corresponding IP.

2) If there is a domain name resolution record in the local DNS, it will be returned to the user directly. If there is no resolution record, the local DNS server will request the resolution record of the domain name www.aliyundoc.com.

3) After the website is connected to the CDN, the www.aliyundoc.com domain name will be resolved by the DNS CNAME resolution record to the domain name www.aliyundoc.com.example.com provided by the CDN accelerator.

4) When the www.aliyundoc.com.example.com domain name finally reaches the CDN server through layer-by-layer analysis, the CDN will distribute the website resources to the nearest user through the CDN dispatching system according to the source IP requested by the user. Edge server, and provide the IP address of the node, which will be used as the resolved address of www.aliyundoc.com.example.com domain name.

5) Alibaba Cloud CDN will return the assigned node IP to the local DNS server. At this time, the www.aliyundoc.com domain name requested by the user has been resolved to the address of the edge server closest to the user through the domain name after CNMAE.

6) The local DNS server will return the resolution record of the domain name to the user.

7) At this time, the user's request to access the website will fall on the best edge server, thereby speeding up the website access. When there is no cached data in the edge server, the CDN will return to the source WEB server, and then cache the data. The server reads, and the user directly obtains the resources of the website from the edge node, speeding up traffic access.

principle

1.4. After the introduction of CDN, domain name resolution becomes CNAME?

When our website introduces a CDN accelerator, the domain name resolution record changes from an A record to a CNAME record. Why?

The main function of the CDN is to distribute the user's request to the edge server closest to the user, and this node provides access to resources, thus speeding up the website access, so how can we know which edge node the user is closest to? In order to solve this problem, the resolution record of the domain name is changed from A record to CNAME record. When resolving the domain name of the source website, the domain name is redirected to the new domain name provided by the CDN, and then DNS is used to resolve the domain name provided by the CDN. Finally, After being resolved to the CDN server, the CDN server can obtain the source IP requested by the user. After obtaining the source IP, the CDN scheduling system can schedule the request on the edge server closest to the user according to the source IP of the request, and Provide the IP address of the edge server, and then pass the IP address back to the local DNS from the CDN server. At this time, the local DNS has obtained the resolution record of the domain name and the best node IP. After the domain name resolution is completed, the website requested by the user at this time The resource will fall to the edge server, speeding up the access of the website.

2. Activate Alibaba Cloud CDN acceleration service

1) Search the CDN accelerator in the console and enter the CDN console.

image-20220127105236489

2) The payment mode of CDN is pay-as-you-go, agree to the terms of service, and click to activate immediately.

image-20220127105329528

3) The CDN service is activated successfully.

image-20220127105430836

Guess you like

Origin blog.csdn.net/weixin_44953658/article/details/132425995