Tencent Cloud CDN Accelerated Configuration Strategy: How to Support Millions of Traffic with the Least Cost

cloud 2026-05-29 阅读 11
2

When your website or App encounters activity promotion, or suddenly comes to a large amount of traffic, the bandwidth of the server will be filled up instantly. At this time, the user's access will be stuck and an error will be reported. If you upgrade the bandwidth of the server without restriction, the gingling silver will evaporate instantly like running water.

In the Internet architecture, the cheapest and most effective line of defense to deal with large traffic and high concurrency is called

CDN (Content Delivery Network)

.

Today we will not talk about the concept of virtual. I'll take you hand in hand to adjust each configuration of tengxunyun CDN to the best, with the least budget, to firmly support the million-level traffic impact.

The first stage: the premise of saving money is to understand the underlying logic of CDN

Why can CDN save money and speed up?

Suppose your server is in Guangzhou. Users in Beijing want to see a big picture, and the traffic has to cross half of China to get it from your Guangzhou server, which is not only slow, but also takes up the precious part of your Guangzhou server.

Public network egress bandwidth

(Bandwidth billing for cloud servers is extremely expensive).

After opening CDN, Tengxunyun has deployed thousands of "cache nodes" around the world ". When a user in Beijing visits, CDN automatically routes the request to a local node in Beijing. If there is a map you want in this node, return directly to the original location.

For users: fast to fly.

For you: the request did not reach your origin server at all, saving the server bandwidth fee. The unit price of CDN traffic is usually only a fraction of the server bandwidth fee, or even lower.

Phase II: Tengxun Cloud CDN Basic Configuration Express

Log in

Tencent Cloud Console

, search for "content delivery network CDN" and click "domain name management"-> "add domain name".

1. Basic property configuration

Domain name: Fill in the domain name you need to accelerate (such as cdn.yourdomain.com or the main website domain name).

Business Type: selected according to actual situation. Select "static acceleration" for static web pages and picture beds. Select "download acceleration" for large file download and installation package distribution ". Select the right business type, Tencent Cloud will allocate different hardware nodes in the background to optimize.

Source station configuration: Select "source station". If you are using Tengxun cloud server, fill in the public network IP of the server directly. Back-to-source protocol: It is strongly recommended to select "HTTP" (provided that your origin server is configured with port 80). Why? Because CDN nodes go to your server to get data (back to the source). If HTTPS is used, the server will frequently perform SSL handshake decryption, which will greatly consume the CPU of the server. The safe way is: users go to CDN through HTTPS and CDN goes to source station through HTTP.

2. Configure CNAME resolution

After adding the domain name, tengxunyun will give you a shape like

xxx.tc.cdntips.com

of/’s

CNAME Domain Names

.

Go to your domain name resolution console (such as DNSPod) and put your accelerated domain name A.

The record is deleted, changed to CNAME record, and the record value is filled in this string.

cdntips

Domain name. After the resolution takes effect, CDN officially intervenes.

The third stage: stingy art-how to drain CDN through "cache configuration"

The core indicator of CDN saving money is called

"Cache Hit Ratio"

. If 100 people access, 99 people get the data directly at the CDN node (hit rate is 99%), and only one person lets the CDN go back to the source station (return rate is 1%), then your server pressure is infinitely close to zero.

Click the domain name in the Tencent Cloud console to enter

Cache Configuration"

This is the core of our operation.

1. Make strict caching rules

Tencent Cloud's default caching rules are very conservative. We need to manually add rules according to the file type. The principle is:

For files that do not change frequently, the cache time can be pulled as long as possible.

.

We recommend that you configure the following three rules:

Rule Type

Content (File Suffix)

Cache time

Explanation and Description

File type

.jpg;.jpeg;.png;.gif;.webp;.ico

30 days

Once the picture is uploaded, it is almost unchanged and cached directly for one month.

File type

. js;.css

7 days

Front-end static style with script, cache for a week. If the front-end version changes the code, force a refresh by adding a version number (such as main.v2.js) to the file name.

File type

.mp4;.mp3;.flv

30 days

Video and audio media files take up a lot of bandwidth and can be kept as long as possible.

2. Core pit avoidance: dynamic content and private data must not be cached.

If your website has a login function, or has a background interface (such

/api/login

,

.php

,

.jsp

), a rule must be added:

Select "folder" or "file type" for type, fill in/api/* or. php for content, and set the cache time to 0 seconds.

If the login interface or the user's personal center is cached, a terrible "serial number" accident will occur (someone else sees your personal data after logging in).

3. Turn on the advanced saving switch

Advanced Cache Configuration-Ignore Case: On. Prevent users from entering LOGO.PNG and logo.png as two files by CDN, resulting in repeated return to the source.

Filter parameters (remove question mark cache): If your picture links are often followed by dynamic parameters (such as image.jpg?version = 1 only to prevent caching or statistics), it is recommended to turn on "filter parameter cache". After opening, no matter what is behind the question mark, CDN will treat it as the same file, greatly increasing the hit rate.

Stage 4: Safety and cost meltdown (to prevent overnight bankruptcy)

CDN is cheap, but it is open to reckoning. If you encounter malicious brush traffic, or peers hire botnet crazy

Carrying your big files and running away hundreds of TB of traffic overnight, the bill can make you want to cry. We have to configure

Security Line of Defense

.

1. Dosage capping configuration (strongest fuse)

In Security Configuration or Advanced Configuration, locate

"Dosage cap"

.

Set a threshold that you can fully afford, for example, if the traffic exceeds 50GB in a single hour or 500GB in that day, immediately automatically shut down the CDN and jump to the source station (or return to 404).

I would rather the website cannot be opened temporarily than bear the unaffordable bill.

2. IP access frequency limit (dimension reduction strike script)

Some malicious crawlers will refresh your web page hundreds of times a second.

Enable IP frequency limiting configuration in the security configuration ".

Set the maximum number of accesses per second for a single IP address. For example, for static acceleration, a normal person can load at most 50 elements per second, and you can set QPS = 60. If the IP exceeds this frequency, CDN will automatically return a 514 error to it and directly shoot it to death at the edge node, which will not be included in your normal settlement traffic.

3. Anti-theft chain setting

Refer to the business you run, open

Referer anti-theft chain

Add your own domain name to the white list. Don't give other websites Bai Piao the chance to traffic your pictures and videos (refer to COS anti-theft chain logic for specific principles and configurations).

The fifth stage: cost optimization-how to choose the billing model?

The default value of Tencent Cloud CDN is usually

"Billed by Flow"

.

If your traffic has obvious peaks and troughs (for example, there are many people during the day and no one at night), or if you are in the initial stage of your business, stick to the option of billing by traffic. At this time, you can go to tengxunyun's resource package mall and purchase "CDN static acceleration traffic package". The unit price of buying a traffic package is more than 30% cheaper than your direct account balance.

If your traffic is very large and very stable all day long (for example, download stations with large traffic and live streaming), you can contact customer service or switch to "charge by bandwidth peak" (for example, charge by 95 per month) at the console, which is more cost-effective for large customers.

Summary

CDN is not finished and everything will be fine. After one week of configuration, log in to the console to take a look.

"Traffic Analysis-> Cache Hit Ratio"

. If your traffic hit rate reaches

More than 90%

This shows that your configuration is very successful. At this time, the pressure on your server caused by millions of traffic has been diluted to less than one tenth. Keeping the user's silky experience with the lowest budget is the ultimate charm of CDN acceleration.

1
← 返回新闻中心