CDN Content delivery network
Content Delivery Network or Content Distribution Network (CDN) reduces the load of the core system (system, Network) by distributing the Content from the source site to the node closest to the user. Users can obtain the required content nearby, improve the response speed of user access. This technical solution solves the problem of access delay caused by distribution, bandwidth and server performance, and is suitable for image small file, large file download, AUDIO and video on demand, full station acceleration and security acceleration.
The working principle of
Through the server placed throughout the network node of a layer of intelligence on the basis of the existing Internet virtual network, CDN system can in real time according to the network traffic and each node connections, load condition and to the user’s distance and comprehensive information such as response time will the user’s request to guide users closest service node.
CDN can be expressed as:
CDN = more intelligent mirroring + cache + traffic diversion;Copy the code
To put it simply, CDN is an overall system strategically deployed, including distributed storage, load balancing, redirection of network requests and content Management. Content Management and global Traffic Management are the core of CDN.
The simplest CDN consists of a DNS server and several cache servers. Assume that your accelerated domain name is www.taobao.com. After you access the CDN and start using the accelerated service, when the end user (Guangzhou) initiates an HTTP request, the process is as follows:
The working process
-
When a terminal user (Guangzhou) sends a request to a resource under www.taobao.com, the terminal user sends a domain name resolution request to LDNS (local DNS).
-
LDNS checks whether the IP address of www.taobao.com is recorded in the cache. If yes, it is returned directly to the end user. If no, consult the authorized DNS.
-
When the authorized DNS resolves www.taobao.com, the IP address of domain name CNAME www.taobao.alicdn.com is returned.
-
The domain name resolution request is sent to the DNS scheduling system and the optimal node IP address is assigned to the request.
-
LDNS Obtains the resolved IP address returned by the DNS.
-
The user obtained the resolved IP address.
-
The user initiates an access request to the obtained IP address.
-
If the node corresponding to the IP address has cached the resource, the data is directly returned to the user, for example, in steps 7 and 8 in the figure, and the request ends.
-
If the node corresponding to the IP address does not cache the resource, the node requests the content to its superior cache server until the source of the traced website initiates a request for the resource. After obtaining the resources, cache the resources to the node (for example, the Hangzhou node on the way) based on the user-defined cache policy and return the resources to the user. The request ends.
The Local DNS is usually the DNS provided by your carrier. Generally, the first destination for domain name resolution is the source HOST. The source HOST refers to the site domain name accessed by the CDN at the source site during the CDN return to the source site.
-
In Step 4, the DNS scheduling system can implement load balancing. Load balancing is classified into global load balancing and regional load balancing. Its internal logic is as follows:
-
Based on the USER IP address and URL of the requested content, the CDN selects a LLB device of the region to which the user belongs and sends the request to the CDN.
-
The LLB will select an appropriate cache server to provide services for users based on the following criteria:
-
Determine which server is closest to the user based on the user IP address.
-
The carrier of the user;
-
According to the content name carried in the URL requested by the user, determine which server has the content required by the user;
-
Query the current load of each server and determine which server has service capability. Based on the above analysis, the LAN load balancer returns the IP address of a cache server to the global load balancer.
- The global load balancer returns the IP address of the server to the user.
Part of the
A typical CDN system consists of the following three parts:
-
Distribution service system: the most basic unit of work is the Cache device, Cache (edge Cache) is responsible for the direct response to the end user’s access request, cached local content quickly provided to users. In addition, the Cache synchronizes the content with the source site. The updated and unavailable content is obtained from the source site and saved locally. The quantity, scale, and total service capacity of Cache devices are the most basic indicators to measure the service capacity of a CDN system.
-
Load balancing system: schedules the access of all users who initiate service requests and determines the actual access addresses provided to users. The two-level scheduling system is divided into global load balancing (GSLB) and local load balancing (SLB). GSLB optimizes each service node to determine the physical location of the Cache that provides services to users based on the proximity principle. SLB is responsible for device load balancing within nodes
-
Operation management system: it is divided into operation management and network management subsystem, which is responsible for the collection, sorting and delivery work necessary for the interaction between business level and external system, including customer management, product management, billing management, statistical analysis and other functions.
A CDN is typically handled by the source station for content production and the trunk node for level 2 caching and acceleration, usually in a BGP network.
Broadly defined content delivery networks can include source sites together and even multimedia distribution (video). CDN in the commercial sense only includes the network of CDN provider, not the source site. Some CDN support image and multimedia processing extension and other additional functions: compression, cutting, watermark, yellow.
CDN section
CDN data flow direction
Application scenarios
Speed up
Site or application of the acceleration of a large number of static resources distribution, proposed to site content of dynamic and static separation, dynamic files can be combined with cloud server ECS, static resources such as various types of HTML, CSS, JS, pictures, documents, short video etc., Suggestions combined with object storage OSS to store huge amounts of static resources, can effectively accelerate the content loading speed, Easily distribute pictures, short videos and other content on the website.
It is recommended to combine CDN products with OSS products to speed up the loading of resources and improve the efficiency of distributing pictures and short videos on websites.
Business value:
-
Slow access by end users: The opening speed of many small files on a website is slow
-
Poor cross-region access quality: End users are distributed in different regions, and the access speed and quality vary from region to region
-
High concurrency and great pressure: during operation and promotion, the source server is under great pressure and is easy to hang down, resulting in service unavailability
-
Image format resolution processing is complex: image compression and optimization cannot be carried out according to the appropriate terminal conditions
Hyperfile download
Large file download optimization and accelerated distribution: The main services of a website or App are to download large files, such as installation package apK, audio file MP3, driver EXE, and application update zip. The average size of a single file is more than 20M, such as games, various client downloads, and App download stores.
The business value
-
End users cannot download or the download is slow.
-
When the network environment is unstable, the download may be interrupted. Redownloading will cost additional resources.
-
The content is insecure and vulnerable to hijacking.
-
The file storage cost is high and the performance of the source station is high.
VoD
Audio and Video on demand optimization and acceleration service: the main business of the website or App is video on demand or short video. Support: MP4, FLV, RMVB, WMV, HLS and other mainstream video formats.
Vod mainly applies to all kinds of video and audio sites, such as film and television video sites, online education video sites, news video sites, short video social networking sites and audio related sites and applications.
CDN supports streaming media protocols, such as RTMP. In many cases, this acts as a proxy that reads content from the upper level cache and forwards it to the user. Because streaming media is often continuous, it can be pre-cached or pushed to the user’s client.
For static pages, content distribution often takes the form of pull, that is, when a miss is found, then go to the next level for pull. However, due to the large amount of streaming media data, if there is a back source, the pressure will be high. Therefore, the mode of active push is often adopted to actively push hot data to edge nodes.
For streaming media, many CDNS also provide pre-processing services, that is, files are processed before distribution. For example, video is converted into different code streams to meet the user needs of different network bandwidth; For example, video sharding reduces storage pressure and allows the client to load different fragments at different bit rates. This is what we usually see, ultra clear, standard clear, smooth and so on.
The business value
-
When the terminal user accesses the video, the video cannot be opened or the video is easily blocked, resulting in poor viewing.
-
The development and configuration process of upload, transcoding, storage, distribution and playback is complicated, and the technical threshold of voD service is high.
-
Video resources are easy to be hijacked or stolen, and the copyright can not be effectively protected.
-
Videos uploaded by terminal customers cannot be quickly reviewed, resulting in policy risks.
measure
Using CDN acceleration can help you share the source station pressure and speed up resource access. In addition to the general data observation indicators, there are also more specific indicators in different scenarios. By observing these indicators, you can not only experience the effect of CDN acceleration, but also observe the use of CDN in your own services to help you make better adjustments and decisions.
General indicators
You can observe the status of your website before and after using CDN according to the following major performance indicators. These indicators include but are not limited to:
-
Latency: The round-trip time for a packet to be sent from the user’s computer to the web server and then immediately returned from the web server to the user’s computer. The lower the latency, the better the performance.
-
Download speed: refers to the transmission speed of data downloaded from the network or network server. The faster the download, the better the performance.
-
Open speed: refers to the speed at which the user opens the site. The faster you open, the better you perform.
-
Packet loss rate: indicates the ratio of the number of packets lost to the sent data group during network transmission.
-
Source back rate: The source back rate is classified into the proportion of the number of return requests and the proportion of return traffic.
-
Number of return requests ratio: the ratio of requests that are not cached, cache expired (cacheable), and not cacheable to all request records of edge nodes. The lower the better the performance.
-
Return source traffic ratio: The return source traffic is the traffic generated by the file size of the return source request and the traffic generated by the request itself. Therefore, the ratio of traffic back to source is equal to traffic back to source/(Traffic back to source + traffic requested by users). The lower the ratio, the better the performance.
-
-
Cache hit ratio: refers to the ratio of the cache times to the total access times when an accelerated node is accessed by an end user. The higher the cache hit ratio, the better the performance.
Note: The source return rate and cache hit ratio mentioned above refer to indicators measured after using CDN. If you are not using a CDN, the number of back requests is 100% and the cache hit ratio is 0.
In general, after using CDN, your network delay, packet loss rate, and source back rate will be reduced, while the relative download speed, open speed, and cache hit ratio will be improved. However, due to different service scenarios and service types, the actual acceleration effect varies even if the SAME CDN service is selected. Therefore, qualitative indicators are only provided here for observation.
Each application scenario of CDN has some specific indicators. You can take further observations based on your business scenario.
Accelerate the main indicators of small files
Small files, mainly refers to HTML, JS, JPG, CSS and other file suffixes web page materials. This kind of acceleration requires a lot of latency, because in general, longer page load times have a huge impact on user churn.
The latency includes three performance indicators: connection establishment time, first package time, and content download time. Among them, the first package time is the most core index.
-
Connection establishment time: indicates the process of establishing a TCP connection after DNS resolution is complete and the corresponding IP address is found. The connection establishment time can basically reflect the node resources and scheduling capability of CDN service.
-
First packet time: the time between the client sending a request and receiving the first packet from the server. This reflects the overall performance of CDN service node program.
In the upload path, the first packet time mainly includes DNS resolution time, TCP time, SSL time, send time, and response time. upload
Key indicators for accelerating large file downloads
Large file download refers to the download of a file larger than 20 MB. Therefore, the key metrics for such scenarios are download speed and total download time.
Accelerate the main indicators of voD
Video audio on demand scene, mainly covering FLV, MP4, WMV, MKV and other video and audio files. The main metrics in this scenario include premiere time and holdout rates:
-
Premiere time: The premiere time is between opening and viewing the video. Often affected by domain name resolution, connection, first packet time.
-
Stalling rate: Stalling refers to the occurrence of frame lag in scenes such as video and audio playback and resource loading. Therefore, the lag rate mainly refers to the report of the lag time of all users playing videos, and the ratio of the lag time in every 100 users playing videos. The lower the holdup rate, the better the performance.
CDN provider
The configuration information of each CDN service provider is different.
-
Ali cloud
-
Tencent cloud
-
Huawei cloud
-
Seven NiuYun
Dynamic CDN
Dynamic acceleration Accelerates the distribution of dynamic resources.
-
Edge computing mode: since the data is dynamically generated, the logical computation and storage of the data are also placed on the edge nodes accordingly. It synchronizes the stored data from the source data periodically and computes the results at the edge. Just as the cooking of fresh food is dynamic, there is no way to cache it in advance, so putting fresh food supermarket next to your home, which can be delivered to your door, and can also be cooked on site, is also an embodiment of edge computing.
-
Path optimization mode: data is not calculated and generated at the edge, but generated at the source station, but the path can be optimized through the CDN network when data is delivered. Because there are many CDN nodes, edge nodes close to the source station and users can be found. The intermediate link is completely planned by CDN, and a more reliable path is selected for access in a way similar to private lines.
For common TCP connections, data is often lost during transmission over the public network. As a result, the TCP window is always small and the transmission speed is slow. According to the principle of TCP flow control and congestion control, TCP parameters can be adjusted in CDN accelerated network, so that TCP can transmit data more aggressively. You can reuse a connection over multiple requests, ensuring that each dynamic request arrives. Connections are already established, so there is no need to temporarily triple shake or create too many connections that strain the server. In addition, transmission efficiency can be increased by compression of transmitted data. All of these means are like cold chain transportation, the whole logistics is optimized, the whole frozen high-speed transportation. Whether fresh is delivered to your house from your local supermarket or from the place of origin, make sure it arrives fresh.
Refresh the preheating
-
The refresh function means that after submitting a REQUEST for URL refresh or directory refresh, the CDN node’s cache content will be forcibly expired. When you request resources from the CDN node, the CDN will directly return to the source site to obtain corresponding resources and return them to you, and cache them. The refresh feature reduces the cache hit ratio.
-
The preheating function means that after submitting a URL preheating request, the source site will proactively cache the corresponding resources to the CDN node. When you make your first request, you can directly obtain the latest requested resources from the CDN node cache without going back to the source site to obtain them. The warm-up feature improves cache hit ratio.