当前位置:网站首页>Alibaba cloud CDN practice
Alibaba cloud CDN practice
2022-07-28 22:15:00 【Leisurely summer】
Mainstream CDN Service providers include Alibaba cloud 、 Hua Wei Yun 、 Tencent cloud 、 Web host technology 、 LAN xunyun, etc .
1、 Alibaba cloud CDN brief introduction
Alibaba cloud has 2800+ node . In mainland China ( mainland ) Have 2300+ node , Cover 31 A provincial region , A large number of nodes are located in the provincial capital and other first tier cities . overseas 、 Hong Kong, China, 、 Macao, China and Taiwan, China, China have 500+ node , Cover 70 Multiple countries and regions . meanwhile , All Alibaba cloud nodes are connected to 10 Gigabit network cards , The storage capacity of a single node is up to 40TB~1.5PB, Bandwidth load reaches 40Gbps~200Gbps, Have 130Tbps Bandwidth reserve .
(1) Alibaba cloud CDN The main application scenarios include :
- Picture small file : If your website or application App Our main business is downloading pictures and small files , Including all kinds of pictures 、html、css、js Small papers, etc .
- Big file download : Website or app App Our main business is downloading large files , The average single file size is 20M above , As the game 、 Various client downloads and App Download stores, etc .
- Video and audio on demand : Website or app App Our main business is video on demand or short video . Support MP4、FLV And other mainstream video formats .
- Speed up the whole station : Whole site acceleration is an independent product of Alibaba cloud , Mainly used for dynamic content acceleration , It can also realize the acceleration of dynamic and static separation .
- Safe acceleration : If your website is vulnerable to attack and must take into account the accelerated business scenario , You need to use the safe acceleration function , Improve the safety of the whole station .
(2) Alibaba cloud CDN working principle
Suppose the acceleration domain name is www.a.com , Access CDN The Internet , After you start using the accelerator , When the end user ( Beijing ) launch HTTP When asked , The processing flow is shown in the figure below .

- When the end user ( Beijing ) towards www.a.com When a request is initiated by the specified resource under , First of all to LDNS( Local DNS) Initiate domain name resolution request .
- LDNS Check the cache for www.a.com Of IP Address record . If there is , It is returned directly to the end user ; without , To authorize DNS Inquire about .
- When authorizing DNS analysis www.a.com when , Return to domain name CNAME www.a.tbcdn.com Corresponding IP Address .
- The domain name resolution request is sent to alicloud DNS Scheduling system , And assign the best node... To the request IP Address .
- LDNS obtain DNS Parsing returned IP Address .
- User get resolution IP Address .
- Users get from IP Address initiates an access request to the resource .
- If it's time to IP The node corresponding to the address has already cached the resource , The data will be returned directly to the user , for example , The steps in the picture 7 and 8, End of request .
- If it's time to IP The node corresponding to the address does not cache the resource , Then the node sends a request for the resource to the source station . After obtaining resources , Combined with user-defined configuration of the cache strategy , Cache resources to nodes , for example , The Beijing node in the picture , And return to the user , End of request .
2、 Use CDN


2.1、 Opening CDN service
(1) Prerequisite :
Before performing this article , Please ensure that you have completed Alibaba cloud account registration and real name authentication .
(2) Operation steps :
Log in to alicloud CDN platform .
Click open now .
Choose the billing type that suits you , And select the service agreement .

Click open now .
Successfully opened CDN After service , You can click management console , Get into CDN Console .

2.2、 Add acceleration domain name

If needed CDN Accelerate business on designated websites , You need to use the website as the source site , Create an accelerated domain name for it .CDN Cache resources on the origin site to by accelerating the domain name CDN The acceleration node of , Accelerate resource access .
(1) Operation steps :
- Sign in CDN Console .
- On the left navigation bar , Click domain name management .
- On the domain name management page , Click Add domain name .
- Configure accelerated domain name 、 Resource grouping 、 Business types 、 Origin information 、 Ports and acceleration areas .


Description of source station information parameter values :
# IP: Support multiple server extranets IP, Alibaba cloud ECS Of IP Audit exemption
# Origin domain name : Support multiple origin domain names
# OSS domain name : Alibaba cloud OSS Bucket Internet domain name
# Function to calculate the domain name : Select function calculation area and domain name
Port parameter value description :
# 80 port CDN Return to the source of the request 80 port .
# 443 port CDN Return to the source of the request 443 port .
Click next

When you speed up the domain name approval , It will appear in the domain name list of domain name management . The status is normal operation , Indicates successful addition .
2.3、 To configure CNAME
After the domain name is added successfully , Alibaba cloud CDN Will assign the corresponding CNAME Address . If enabled CDN Accelerated Service , You need to point the accelerated domain name to CNAME Address , Requests for access to accelerated domain names can only be forwarded to CDN Node , Achieve acceleration effect .
Get the CNAME Address .
(1) Get the CNAME Address .
- Sign in CDN Console .
- On the left navigation bar , Click domain name management .
- Enter the domain name management page , Copy the acceleration domain name CNAME value .

(2) add to CNAME Record .
This step is used to resolve in Alibaba cloud DNS The console adds CNAME Record as an example , Let me introduce you to CNAME Configuration process of . If you are in DNSPod、 New network 、Godaddy Domain name resolution set by other domain name resolution service providers , Please go to the corresponding domain name resolution service provider to add CNAME Record , The addition method is similar to the method introduced in this article .
- Log in to alicloud to resolve DNS Console .
- Enter the domain name resolution page , After the domain name you need to set up , Click resolve settings .
- Click Add record , add to CNAME Record .


explain
- Record type : choice CNAME .
- Host record : Accelerate the prefix of domain name .

- Analytic circuit : The default value is .
- Record value : Enter the... Corresponding to the accelerated domain name CNAME Address .
- TTL: The default value is .
Click OK .
- Successfully configured CNAME And after it takes effect , The acceleration service will take effect immediately .
(3) verification CNAME Whether the configuration is effective .
- open Windows Of CMD Command line program .
- On the command line ping Accelerate domain name , If the returned parsing result is the same as CDN On the console, the domain name should be accelerated CNAME Value consistent , said CDN The acceleration has taken effect .

3、 Service management
If monitoring is required 、 Statistical analysis 、 Usage query 、 Refresh preheating 、 Log analysis, etc CDN Manage resources , You can use Alibaba cloud CDN The service management function provided by the console . Through this function, you can analyze in real time and effectively CDN Health , And make business decisions in time .
Alibaba cloud CDN List of service management functions :


Refresh preheating
CDN Provide the function of refreshing and preheating resources . Through the refresh function , You can force CDN The node returns to the source and gets the latest file ; Through the preheating function, hot resources can be preheated during business peak , Improve resource access efficiency .
CDN The concept of the refresh and warm-up functions of the resources provided is as follows :
- The refresh function refers to submitting URL After refresh or directory refresh request ,CDN The cached content of the node will be forced to expire , Direction CDN When a node requests a resource ,CDN It will go back to the source station directly to get the corresponding resources and return them to you , And cache it . The refresh function will reduce the cache hit rate . Use scenarios : Usually, static resources are updated in the source site . Take the initiative to load the latest resources from the edge node .
- The warm-up function refers to submitting URL After warm-up request , The origin will actively cache the corresponding resources to CDN node , When first requested , You can go straight from CDN Get the latest request resource from the node cache , There is no need to go back to the source station to get . The cache warm-up function will improve the cache hit rate .
Operation steps :
- Sign in CDN Console .
- On the left navigation bar , Click refresh preheating .
- In the refresh cache tab , You can do as you need , Configure refresh or warm-up information .
- Click Submit
- Click operation record
- On the operation record tab , Configure query time 、 Operation type 、 Domain name or URL, Click query .

The detailed description of the refresh and warm-up functions is shown in the following table .

4、 Domain name management
4.1、 Back to source configuration
When requesting access to resources through the client , If CDN The resource is not cached on the node , You will go to the source station to get , Cache to CDN node . You can configure the related functions of returning to the source according to your needs , Improve resource access efficiency .
| function | explain |
| Configure back to source HOST | When you need to customize CDN When the node returns to the source, it needs to access the specific server domain name , Need to configure back to source HOST Type of domain name . |
| Configure the back to source protocol | When requesting access to resources through the client , If CDN The resource is not cached on the node , Then it will follow the rules to the source station to obtain resources according to the configured Protocol , Cache to CDN node . |
| Open private Bucket Back to source authorization | When the origin is OSS( Alibaba cloud cloud storage ) when , You can open accelerated domain name access private OSS Bucket Resource permissions , Effectively prevent resource theft . |
| Close private Bucket Back to source authorization | Can pass RAM Console , Cancel the authorization of the corresponding role name , Close private Bucket Back to source function . |
| Configure back to source SNI | If the origin IP Bound multiple domain names , When CDN Node to HTTPS When the protocol accesses your origin , You can set back to the source SNI, Specify the specific access domain name .SNI(Server Name Indication) yes TLS An extension of , To solve a The server has multiple domain names . |
| Configure custom back to source HTTP head | HTTP When requesting a return to the source , You can add or delete back to the source HTTP head . |
| Configure the timeout of the request back to the source | CDN The timeout waiting time of the back to source request of the acceleration node defaults to 30 second , It can be set according to actual needs CDN The longest waiting time for a request back to the source . When the waiting time of the request back to the source exceeds the configured timeout ,CDN The connection between the node and the source station is disconnected . |
4.2、 Cache configuration
CDN When accelerating static resources , Cache the resources on the origin to the nearest to the client CDN Node . When accessing the static resource , Get directly from the cache , Avoid going back to the source over a long link , Improve access efficiency .

| function | explain |
| Configure cache expiration time | You can specify the cache expiration time of directory and file suffix for static resource configuration , And priority , Make it CDN Cache according to cache rules . |
| Configure the expiration time of the status code | You can configure the expiration time of the status code of the specified directory or file suffix of the resource . |
| To configure HTTP head | You can configure the resource cache to expire HTTP The message header . |
| Custom error page | You can customize it according to your needs HTTP perhaps HTTPS The response return code jumps completely URL Address . |
| Configuration override | You can respond to the requested URI Make modifications and 302 Redirect to target URI. |
4.3、 Access control
Can be set by Referer、IP、UsageAgent Blacklist and whitelist , as well as URL authentication , To realize the identification and filtering of visitor identity , To restrict access to CDN Users of resources , promote CDN The security of .
| function | explain |
| To configure Refer Anti theft chain | You can access through configuration Referer Black list and white list to identify and filter the identity of visitors , Limit access to CDN Users of resources . |
| To configure URL authentication | You can configure URL The authentication function protects the resources of the user site from being downloaded and misappropriated by illegal sites .URL Authentication ratio Referer The security of anti-theft chain is higher . |
| To configure IP Black and white list | You can configure IP Black list and white list to identify and filter the identity of visitors , Limit access to CDN Users of resources . |
| To configure UA Black and white list | You can configure UsageAgent Black list and white list to identify and filter the identity of visitors , Limit access to CDN Users of resources . |
4.4、 performance optimization
Set the performance optimization function of accelerating the domain name , Reduce the size of access files , Improve the efficiency of accelerating business and page readability .
Carry a pair of 11 Flow peak : With the national acceleration node 、 Intelligent flexible scheduling system and security protection capability , Perfectly support billions QPS Peak value , Ensure that hundreds of millions of buyers around the world can quickly browse high-definition pictures and videos , Order smoothly . Through the performance optimization function , Perform the following operations on the domain name .

| function | explain |
| Page optimization | When you turn on the page optimization function ,CDN Automatic removal of HTML Redundant comments and repeated white space characters on the page , Reduce file size , Improve page readability . |
| Intelligent compression | When you turn on the intelligent compression function ,CDN The static file is automatically Gzip Compress . Through intelligence Gzip Compression way , It can effectively reduce the size of the transfer file , Improve the efficiency of accelerating business . |
| Brotli Compress | When you need to compress static text files , You can turn on this function , Effectively reduce the size of transmission content , Speed up the distribution effect . |
| Filter Parameters | When your URL The request carries a question mark (?) And parameters ,CDN Node is receiving URL After the request , Judge whether it is necessary to carry parameters URL Return to the origin . |
4.5、 Video related
Can be set by Range Back to source and drag and drop play function , Reduce the consumption of return flow , And improve the playback effect of video and audio .
Through video related functions , Perform the following operations on the domain name .
| function | explain |
| Range Back to the source | Turn on Range Back to source function , It can reduce the consumption of back to source traffic , And improve resource response time . |
| Drag play | After the drag and play function is enabled , When playing video and audio , Drag and drop the playback progress at will , Without affecting the playback effect of video and audio . |
边栏推荐
- 2021年数学建模B组代码
- 第 8 篇:创建摄像机类
- [machine learning] naive Bayesian classification of text -- Classification of people's names and countries
- Learn kotlin - extension function
- array_ diff_ The method of not comparing array values when Assoc element is an array
- 2021数学建模B组练习
- Bugku,Web:都过滤了
- 如何高效、精准地进行图片搜索?看看轻量化视觉预训练模型
- kubevela插件addons下载地址
- The person in charge of Tencent cloud database borrowed 100 million yuan to speculate in stocks? Insider: the amount is not true
猜你喜欢

搞事摸鱼一天有一天

Implementation of sequence table

Openeuler embedded sig | distributed soft bus

【NLP】生成词云

Part 8: creating camera classes

AimBetter洞察您的数据库,DPM 和 APM 解决方案

DHCP and PPPoE protocols and packet capture analysis

2021数学建模B组练习

节省70%的显存,训练速度提高2倍!浙大&阿里提出在线卷积重新参数化OREPA,代码已开源!(CVPR 2022 )
![[hero planet July training leetcode problem solving daily] dynamic planning on the 28th](/img/79/bc763bb6f12c525454abda18be4265.png)
[hero planet July training leetcode problem solving daily] dynamic planning on the 28th
随机推荐
HYDAC溢流阀DB08A-01-C-N-500V
字节一面:TCP 和 UDP 可以使用同一个端口吗?
科大讯飞笔试
小程序 组件 定时器的清除
Msfvenom makes master and controlled terminals
从 Web3到Web2.5,是倒退还是另辟蹊径?
IFLYTEK written examination
行内元素和块级元素有什么区别?语义化作用
HYDAC overflow valve db08a-01-c-n-500v
系统分析师
Summary of the use of hash table set and map when leetcode brushes questions
罗克韦尔AB PLC RSLogix数字量IO模块基本介绍
hcip实验(12)
C语言编程规范学习笔记和总结
【机器学习】朴素贝叶斯对文本分类--对人名国别分类
kubevela插件addons下载地址
msfvenom制作主控与被控端
2021年数学建模B组代码
Which brand is the best and most cost-effective open headset
The difference between get and post