Introduction to Alibaba Cloud CDN Acceleration Principles

What is Alibaba Cloud CDN

Alibaba Cloud Content Delivery Network (CDN for short) is a distributed network that is established and overlaid on the bearer network and consists of edge node server groups distributed in different regions. Alibaba Cloud CDN shares the pressure on the source site, avoids network congestion, ensures faster distribution of website content in different regions and scenarios, and improves resource access speed. 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. 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. To facilitate understanding, let’s take another simple example. Assume that there are two L1 nodes, Hangzhou Mobile Node Cache1 and Ningbo Mobile Node Cache2. These two L1 nodes both return to the same L2 node, and the source station is in 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 Cache1 node by the CDN. Since Cache1 has no cache, it returns to L2. Since L2 has no cache, it returns to the source station in Beijing. After requesting data, it returns to Cache1, and L1 returns again. to user A.

After user A completes the request, both Cache1 and L2 nodes have cache resources. At this time, Hangzhou Mobile user B also starts to access this picture, and user B is also assigned to the Cache1 node. Since Cache1 already has the cache of this picture, Cache1 does not need to go back to the source, but directly returns the cache to user B.

Ningbo mobile user C also accessed the same picture at this time, and user C was assigned to Ningbo mobile node Cache2. Since Cache2 has not cached it, it will return to L2, and L2 already has a cache, so L2 will directly return the cached data to Cache2, and then Cache2 returns to user B. In this process, there is a process of Cache1 returning to the source to L2, and L2 does not need to go back to the source.

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

In the resources requested by HTTP, requests can be divided into static content and dynamic content.

Static content (static resources)

Static content refers 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 Content (Dynamic Resources)

Dynamic content refers 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.

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