当前位置:网站首页>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
边栏推荐
- I have an agreement with IOT
- Library management backstage
- 3. go deep into tidb: perform optimization explanation
- Advanced authentication of uni app [Day12]
- Introduction to C language custom types (structure, enumeration, union, bit segment)
- 2020年Android面试题汇总(中级)
- getAttribute 返回值为null
- 事件
- Web penetration test - 5. Brute force cracking vulnerability - (5) SMB password cracking
- Backup method of mysqldump
猜你喜欢

apipost接口断言详解

Kubernetes resource topology aware scheduling optimization

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

Idea创建Servlet 后访问报404问题

External network access SVN server (external network access SVN server deployed on the cloud)

Abnova membrane protein lipoprotein solution

SAP mts/ato/mto/eto topic 8: ATO mode 2 d+ empty mode strategy 85

Introduction to C language custom types (structure, enumeration, union, bit segment)

阿里云新一代云计算体系架构 CIPU 到底是啥?

博士申请 | 香港科技大学(广州)刘浩老师招收数据挖掘方向全奖博士/硕士
随机推荐
Go operation mongodb
Beauty of script │ VBS introduction interactive practice
What is etcd and its application scenarios
Database answers build standard, answer as required
External network access SVN server (external network access SVN server deployed on the cloud)
IDC, Youshang cloud data on cloud (COS) best practices
Opengauss version 3.0 source code compilation and installation guide
Backup method of mysqldump
The results of the 2022 open source summer were announced, and 449 college students will contribute to open source projects
图书馆管理后台
2022年二级造价工程师备考攻略,你准备好了吗?
web渗透测试----5、暴力破解漏洞--(9)MS-SQL密码破解
3. go deep into tidb: perform optimization explanation
MySQL - SQL execution process
SAP mts/ato/mto/eto topic 7: ATO mode 1 m+m mode strategy 82 (6892)
How to adjust the alarm information that remains unchanged after paging is selected on the easygbs alarm page?
SAP MTS/ATO/MTO/ETO专题之七:ATO模式1 M+M模式策略用82(6892)
Worthington胰蛋白酶的物化性质及特异性
Kubernetes resource topology aware scheduling optimization
C语言自定义类型的介绍(结构体,枚举,联合体,位段)