Handling Massive Traffic Spikes for a Forum Using Elastic Scaling, CDN, and Staticization on Tencent Cloud
To cope with a sudden, X5‑driven traffic surge that overwhelmed a migrated forum’s servers, the team enabled elastic scaling, redirected missing avatars with soft‑404 responses, off‑loaded avatar and post requests to a CDN, and created a pseudo‑static domain, allowing a single modest server to sustain massive loads.
Since 2012, Tencent redirected the 404 pages of its internal services to the "Baobei Home" (宝贝回家) project, and in 2013 opened the 404 redirection to third‑party sites. The resulting traffic pressure forced the forum to be migrated to Tencent Cloud for more stable service.
During the National Day holiday, volunteers noticed the site becoming slow and eventually inaccessible. Log analysis showed a sharp increase in traffic, suspected to be a CC attack. After enabling various protections, the traffic remained high, so elastic scaling was turned on to automatically add instances when the machines could not cope.
Further log analysis revealed that avatar requests had surged hundreds of times, dominating the logs. The avatars were off‑loaded to a CDN, but the CDN could not cache missing avatars (404). The server was therefore configured to return a default avatar with a 200 status (“soft 404”) to avoid unnecessary 404 responses.
After these measures, traffic decreased, but a new surge of tens of times the original volume appeared, almost entirely from Android devices. It turned out that the traffic was driven by the X5 kernel, Tencent’s mobile browser engine used in WeChat, Mobile QQ and other Android apps.
The root cause of the avatar surge was identified: Discuz mobile displays all commenters’ avatars without the lazy‑loading and static‑link optimizations that the PC version uses, leading to a much higher avatar request count.
To mitigate this, the avatar template was modified. The original code:
<span class="avatar"><img src="<!--{if !$post['authorid'] || $post['anonymous']}--><!--{avatar(0, small, true)}--><!--{else}--><!--{avatar($post[authorid], small, true)}--><!--{/if}-->" style="width:32px;height:32px;" /></span>was changed to:
<span class="avatar" style="zoom:0.62">
<!--{if !$post['authorid'] || $post['anonymous']}--><!--{avatar(0, small, false, false, true)}--><!--{else}--><!--{avatar($post[authorid], small, false, false, true)}--><!--{/if}-->
</span>This adopts the PC‑side avatar link generation method and adds a zoom factor to compensate for the larger PC avatar size.
Even after reducing avatar load, the forum posts themselves became the main pressure source. Discuz supports pseudo‑static URLs but not true static pages because it needs to render personalized content for logged‑in users and serve different versions for PC, mobile, pad, and WAP clients.
Given that over 90% of the traffic originated from X5‑driven apps (mostly anonymous Android users), the team created a dedicated domain 404.baobeihuijia.com that proxies the forum through a CDN with cache‑through and uses Discuz’s pseudo‑static links to emulate true static pages. Two additional steps were taken for client compatibility:
Modify the backend PHP to always return the mobile version of a post when the request comes via the new domain.
On the static page, detect non‑mobile clients via script and redirect them back to the original domain bbs.baobeihuijia.com for dynamic service.
After these changes, the CDN off‑loaded the majority of the new traffic, and a single server could handle the remaining load. The final architecture, despite its modest configuration, proved capable of withstanding the massive X5‑driven traffic thanks to Tencent Cloud’s robust performance.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Tencent Cloud Developer
Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
