Detailed Explanation of Alibaba Cloud CDN Acceleration Principle

What is a CDN

The full name of CDN is Content Delivery Network, that is, content distribution network. CDN is an intelligent virtual network built on the basis of the existing network. Relying on the edge servers deployed in various places, through the load balancing, content distribution, scheduling and other functional modules of the central platform, users can obtain the required content nearby and reduce network congestion. Improve user access response speed and hit rate. The key technologies of CDN mainly include node scheduling, node load balancing and content storage, distribution, and management technologies.

Alibaba Cloud CDN

Alibaba Cloud has 3200+ nodes around the world. Mainland China (Mainland) has 2,300+ nodes, covering 31 provincial-level regions, and a large number of nodes are located in first-tier cities such as provincial capitals. Overseas, Hong Kong, Macau and Taiwan have 900+ nodes, covering more than 70 countries and regions. At the same time, all nodes of Alibaba Cloud are connected to 10Gbps network cards. The storage capacity of a single node reaches 40TB~1.5PB, the bandwidth load reaches 40Gbps~200Gbps, and it has a bandwidth reserve capacity of 180Tbps. Click the document to learn about Alibaba Cloud CDN in three minutes.

Before CDN acceleration

Before CDN acceleration is used, the request initiated by the user side is recursive to the website DNS through the user side DNS for resolution, and the end user side directly requests the website server. Here may cause the following situations:

The load on the central server is too high, because all requests initiated by the client will be requested to the server

The end-user content acquisition delay is high, for example, the server is in Beijing, but the user is in Guangzhou
Poor service stability

After CDN acceleration

By adding a new layer of cache nodes to the existing network, CDN publishes the resources of the source site to the network node closest to the user, so that the client can directly access the nearest CDN node and hit the resource when requesting, reducing the need for back-to-source situation, improve website access speed.

Alibaba Cloud CDN cache nodes can be divided into L1 nodes (first-level nodes) and L2 nodes (second-level nodes). The request process is: client --> CDN_L1 --> CDN_L2 --> origin site. The L1 nodes of the CDN are distributed in various provinces and cities across the country, and the L2 nodes are distributed in several large regions. The L2 nodes can be understood as aggregation nodes. The simple architecture is shown in the figure below.

The CDN node caching strategy is as follows:

1. The client initiates a connection request to the CDN node. When the L1 node has a cache resource, it will hit the resource and directly return the data to the client. When the L1 node has no cached resources, it will request the corresponding resources from the L2 node. If the L2 node has cached resources, the resources will be synchronized to the L1 node and returned to the user; if the L2 node has no cached resources, it will be directly returned to the customer's source site to obtain Resources are cached according to the configured cache policy.

2. For the convenience of understanding, let’s take another simple example. Suppose there are two L1 nodes, Hangzhou mobile node L1-hz and Ningbo mobile node L1-nb. These two L1 nodes both return to the same L2 node. The source station Beijing. These CDN nodes initially do not have user cache resources. When the three users of ABC request the same picture in turn, the process is as follows:

Hangzhou mobile user A is dispatched to Hangzhou mobile L1-hz node by CDN. Since L1-hz has no cache, it will return to L2. Since L2 has no cache, it will return to Beijing source station. After requesting data, it will return to L1 -hz, L1 returns to user A.

After user A completes the request, both L1-hz and L2 nodes have cache resources. At this time, Hangzhou Mobile user B also started to access this picture, and user B was also assigned to the L1-hz node. Since L1-hz already has the cache of this picture, there is no need to go back to the source, but directly return the cache to User B.

Ningbo mobile user C also visits the same picture at this time, and user C is assigned to Ningbo mobile node L1-nb. Since L1-nb has no cache, it will return to L2, and L2 already has a cache, so L2 will directly Return cached data to L1-nb, and then L1-nb returns to user B. In this process, there is a process of returning L1-nb to L2 to the source, and L2 does not need to go back to the source station again.

Through CDN acceleration, users A and B in Hangzhou can directly read the cached data from the Hangzhou node, and user C in Ningbo can directly read data from the Ningbo node without having to request the Beijing server every time, which improves the access speed on the user side. Reduced server pressure.

How CDNs work

Through the following cases, you can further understand the working principle of CDN.
Assume that the acceleration domain name is, access the CDN network, and start using the acceleration service. When an end user (Beijing) initiates an HTTP request, the processing flow is shown in the figure below.

1. When an end user (Beijing) initiates a request to a resource under, it first initiates a domain name resolution request to LDNS (local DNS).

2. LDNS checks whether there is an IP address record of in the cache. If there is, it will be directly returned to the end user; if not, it will be queried to the authoritative DNS.

3. When authorizing DNS to resolve, return the IP address corresponding to the domain name CNAME

4. The domain name resolution request is sent to the Alibaba Cloud DNS scheduling system, and the best node IP address is assigned to the request.

5. LDNS obtains the resolved IP address returned by DNS.

6. The user obtains and resolves the IP address.

7. The user initiates an access request to the resource to the obtained IP address.

If the node corresponding to the IP address has cached the resource, the data will be returned directly to the user, for example, steps 7 and 8 in the figure, the request ends.

If the node corresponding to the IP address does not cache the resource, the node initiates a request for the resource to the source station. After obtaining the resources, combined with the cache policy configured by the user, the resources are cached to the node, for example, the Beijing node in the figure, and returned to the user, and the request ends. For how to configure a cache policy, see Cache Configuration.

pay attention

When the CDN scheduling system allocates nodes, it allocates nodes based on the client's LocalDNS instead of the client's IP. Therefore, if the client's LocalDNS setting is incorrect, it will not be able to allocate and schedule to the optimal node.

What resources can be accelerated

For resources requested by HTTP, requests can be divided into static requests and dynamic requests.
static request
Static requests refer to static files with the same data accessed in different requests. For example: pictures, videos, files in websites (html, css, js), software installation packages, apk files, compressed package files, etc.

The essence of CDN acceleration is cache acceleration, which caches the static content stored on your server on the Alibaba Cloud CDN node. When you access these static content, you can obtain the same content by visiting the nearest Alibaba Cloud CDN node without visiting the source site of the server. So as to achieve the effect of acceleration, while reducing the pressure on the server origin site.

dynamic request

Dynamic requests refer to dynamic content that accesses different data in different requests. For example: files in the website (asp, jsp, php, perl, cgi), API interfaces, database interaction requests, etc.

When the client accesses these dynamic contents, it needs to visit the user's server every time, and the real-time data is dynamically generated by the server and returned to the client. Therefore, CDN cache acceleration is not suitable for accelerating dynamic content, and CDN cannot cache dynamic content that changes in real time. For dynamic content requests, CDN nodes can only forward them back to the origin server, without acceleration.

If the user's website or app application has more dynamic content, for example, various API interfaces need to be accelerated, then Alibaba Cloud site-wide acceleration products are required. Site-wide acceleration can accelerate dynamic and static content at the same time. The acceleration method is as follows:

Static content is accelerated using CDN.

Dynamic content uses Alibaba Cloud's routing optimization, transmission optimization and other dynamic acceleration technologies to access your server source site to obtain data at the fastest speed. So as to achieve the effect of whole station acceleration.

CDN caching strategy

How long static content can be cached on the CDN is based on the CDN's cache policy. If the user does not actively configure the expiration time on the CDN, the CDN's default caching policy will be followed. The default cache time of CDN is relatively short, and the maximum does not exceed 3600 seconds, so it is easy to expire the cache. Because website developers and related technical personnel are more aware of the business logic, static and dynamic factors of their own websites, it is recommended that users set the cache time according to file type and directory through the console.

Users can log in to the Alibaba Cloud CDN console to configure the cache expiration time, and configure the cache expiration time and priority of the specified directory and file suffix name for static resources. After the resource expires, it will be automatically deleted from the CDN node.

Total site acceleration and CDN

Dynamic Route for Content Delivery Network (Dynamic Route for Content Delivery Network) is a CDN product of Alibaba Cloud that combines dynamic acceleration and static acceleration technologies. This product one-stop optimizes the problems of slow response, packet loss, and unstable service caused by many factors such as mixed dynamic and static resources on the page, cross-operator, network instability, single-line source station, burst traffic, network congestion, etc., and improves the overall site performance and user experience. The comparison between full-site acceleration and CDN is as follows

The static acceleration of site-wide acceleration is consistent with the acceleration principle of CDN, which provides users with nearby access for acceleration by caching static resources to edge nodes. The dynamic acceleration of the whole site acceleration is to quickly return to the source through dynamic acceleration technologies such as intelligent route optimization and protocol optimization when dynamic requests are returned to the source.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us