当前位置:网站首页>How to control CDN traffic gracefully in cloud development?
How to control CDN traffic gracefully in cloud development?
2022-06-24 04:39:00 【Tencent cloud development TCB】
In the community , There are a lot of feedback from small partners using cloud development “CDN Flow consumption is like running water ” The situation of .
One day I woke up :
Have been loaded with high quality pictures “ scared ” I dare not use it :
So here comes the question , How to manage gracefully in cloud development CDN Traffic consumption ? This article will talk with you in detail !
01、 Pay as you go and pay as you go
For the sake of understanding , Let's take a look at the traffic billing mode of cloud development first .
Simply speaking , Pay by volume Namely : How many of you ran out , I'll give you the quantity ; But it doesn't limit how much you can run out at the same time , That is, there is no limit to the peak flow .
If you need to run out at the same time 100M The amount of , Then I'll drive you to the peak 100M, Run at the same time , The final cost is 100M The money .
and Pipeline payment It's about limiting how wide it's going to be for you “ road ”, According to this “ road ” Wide and narrow charges of , For example, you choose 1M The road of the Internet , Then according to 1M I'm going to charge you at a reasonable price ; When use , Your quantity can only reach 1M The speed of , It can't be any higher , This maximum speed is called bandwidth .
But even when the low peak doesn't have much , You also have to work for this “ road ” pay . Or the above , You need to run out at the same time 100M, But the speed will only give you to 1M, So these quantities are 100 You can walk in seconds , The final cost is 1M The road rent of * The length of the lease .
And in real projects , There will always be peaks and lows in business , It's almost impossible to keep the flow at a constant rate all the time , This creates a ceiling with speed 、 But the waste of resources that are still charging when idle .
Cloud development as Serverless Cloud native integrated back end service , The traffic provided is paid by volume , Pipeline payment is not supported , Don't limit the flow rate at the same time , therefore , If developers use it unreasonably, it will lead to too fast flow , This will lead to rapid excess flow .
After understanding the difference between pay as you go and pay as you go , Let's get to the point , say something CDN.
02、 What is? CDN Traffic ?
When we use cloud development , You can see it almost everywhere CDN The word .
CDN also called Content distribution network , Generally speaking, it is to store your main memory ( Origin station ) Documents in , Copy to storage points everywhere (CDN node ), When a user accesses this resource , Directly from the nearest storage point (CDN node ) Get it .
Natural support for cloud storage and static website hosting of cloud development CDN Speed up , So the traffic that your users download files through the client is CDN Traffic .
above CDN Traffic is only applicable to all kinds of channels to speed up the downloading of files from the public network , For example, the browser loads the website , Client downloads resources , External system request file , Opening files through various accesses to temporary addresses is consuming CDN Traffic .
But if it's an intranet access file , I will not go CDN Flow consumption , For example, in the cloud function through fileID Access files, etc .
03、 What is? CDN Back to source traffic ?
When we have file updates in our storage , Stored in CDN How to deal with the old file of the node ? Introduce a knowledge point here —— Cache time .
The cache time here is actually the storage point of file copies in different places (CDN node ) Effective time of , For example, the default is two hours , So the effective time of each copy of the file in each storage point is two hours , When you receive a request after this time , Storage point (CDN node ) Will discard old files that are out of date , To the primary storage ( Origin station ) Request the latest file , And the traffic generated by this request is called CDN Back to source traffic .
The cache time cannot be too long or too short , If CDN Cache interval too short , that CDN Data on nodes will often fail , Cause frequent back to source , The load of the source station is increased , And then affect the overall transmission efficiency ; If the cache interval is too long , It will bring serious business problems such as untimely data update .
Cloud storage of cloud development provides very fine-grained cache time settings , You can target a file 、 A path or even a file suffix is used to set it separately .
in addition , There are also priority policies in multiple cache rule settings , Deployment becomes more flexible .
Cloud storage does policy computing in a back to front configuration mode , For example, a cloud storage domain name has the following cache configuration :
Now request resources under this path /test/abc.jpg, The matching method from back to front is as follows :
Match the first all files , hit , The cache time is 2 minute .
Match the second , Not hit .
Match the third , hit , The cache time is 300 second .
Match the fourth , hit , The cache time is 400 second .
Match the fifth , hit , The cache time is 200 second .
04、 How to reasonably control CDN?
We need to grasp a principle :
Reduce the size , Make good use of cache .
Reduce the size It means , When we develop applications , Multimedia files needed , If there are no special requirements ( For example, the original pictures of the camera are sent ), It needs to be compressed as much as possible . Only by reducing the size of business resources , Can fundamentally reduce the consumption of traffic resources .
in addition , When users upload multimedia resources , You can still use platform or framework capabilities to compress resources before uploading them , Ensure that all resources are optimized and stored , This will reduce a lot of load when you request to download .
Make good use of cache It means the same user 、 Try not to request the same resource more than once , To use the client's local caching capability properly , Cache all fixed resources . When the user enters again , Using cached resources directly .
I'd like to give you another golden sentence : The cache works well ,PV The effect is just UV The amount of .
And in specific use , We still need to reasonably grasp it according to our own business situation . For example, your resources change very frequently , It's not suitable for cache optimization ; And your resources can't be compressed , Keep it the same size , It is not suitable for compression optimization .
05、 Conclusion
The above strategy is for you hold Unable to live CDN Friends of traffic , If you think CDN Consumption is like running water , Users are active but not much better , Maybe you need to check where you waste . Thrift is a traditional virtue of the Chinese nation , Cloud development is good , We also need to use it sparingly ~
author : Yunyun senior
边栏推荐
- apipost接口断言详解
- 什么是数据中台
- web渗透测试----5、暴力破解漏洞--(5)SMB密码破解
- The results of the 2022 open source summer were announced, and 449 college students will contribute to open source projects
- 2. in depth tidb: entry code analysis and debugging tidb
- Collagenase -- four types of crude collagenase from Worthington
- 编译器是如何将芯片执行的第一个指令放到芯片起始地址的?
- Kubernetes resource topology aware scheduling optimization
- 梯度下降法介紹-黑馬程序員機器學習講義
- What if the ECS forgets its password? How can I retrieve my forgotten password?
猜你喜欢

Recognize workplus again, not only im but also enterprise mobile application management expert

编译器是如何将芯片执行的第一个指令放到芯片起始地址的?
![Web technology sharing | [map] to realize customized track playback](/img/b2/25677ca08d1fb83290dd825a242f06.png)
Web technology sharing | [map] to realize customized track playback

MySQL - SQL execution process
Summary of Android interview questions in 2020 (intermediate)

外网访问svn服务器(外网访问部署在云上的svn服务器)
uni-app进阶之认证【day12】

Apipost interface assertion details

Abnova peptide design and synthesis solutions

Training course of mixed accuracy from simple to deep
随机推荐
What does IIS mean and what is its function? How does IIS set the size of the web site space on the server?
Ribbon
Chemical properties and specificity of Worthington Papain
我与物联有个约定
How do ECS create FTP accounts? What should I pay attention to during creation?
How can the new generation of HTAP databases be reshaped in the cloud? Tidb V6 online conference will be announced soon!
Huawei cloud gaussdb (for redis) unveiling issue 19: gaussdb (for redis) comprehensive comparison with CODIS
Leetcode refers to offer II 089 House theft
How to install software on ECs is it expensive to rent ECS
How to build a website for ECS is the price of ECS very expensive
Easygbs video playback protocol only webrtc can play. Troubleshooting
Go language Chanel memory model
What is an ECS? What is the difference between ECs and traditional servers?
How to operate ECs and what types of system configuration schemes can be supported
黑马程序员机器学习讲义:线性回归api初步使用
Worthington脱氧核糖核酸酶I特异性和相关研究
ribbon
Weibo International Edition changed its name to Weibo light sharing Edition
How does the compiler put the first instruction executed by the chip at the start address of the chip?
Doctor application | Hong Kong University of science and Technology (Guangzhou) Mr. Liu Hao recruits the full award doctor / Master in data mining