Backend Development 5 min read

Scaling Hot News Articles: FreeMarker, Caching, and Nginx Architecture

This article explains how to design a backend architecture that pre‑generates article HTML with FreeMarker, stores files on cloud servers, caches data in Redis and local memory, and uses LVS, Nginx, and Sentinel to safely handle sudden traffic spikes from viral news.

Lobster Programming
Lobster Programming
Lobster Programming
Scaling Hot News Articles: FreeMarker, Caching, and Nginx Architecture

Why Hot News Causes Traffic Spikes

When a celebrity scandal or breaking news breaks, platforms like Weibo or Toutiao see a rapid surge in clicks, which can overwhelm servers if no proper measures are taken.

Technical Point – FreeMarker

FreeMarker is a Java‑based template engine that generates output text such as HTML pages from templates and data. It integrates easily with SpringBoot.

Article Service Design

To cope with sudden traffic, the article content is pre‑generated into an HTML file using FreeMarker and uploaded to a cloud server. The file URL is stored in MySQL and cached in Redis, while a message containing the article data is sent to a message queue for local cache updates.

Overall Service Design

1. Operators publish hot articles, generate HTML, and upload it to the cloud; the cloud returns the file URL. 2. The backend writes the URL to the database, caches the article info in Redis, and pushes the data to MQ. 3. User requests first pass through LVS, then Nginx, and finally the gateway. Sentinel performs rate‑limiting and protection. The service checks the local cache, falls back to Redis, and ultimately queries the database if needed. 4. The client receives the article URL, downloads the pre‑generated HTML from the cloud server, and displays the page.

Summary

For hot articles, pre‑create HTML with a template engine, upload to cloud storage, cache metadata in local and distributed caches, and let clients fetch the static HTML directly, thereby reducing load on the backend services.

backend architecturecachingnginxSpringBootHigh Trafficfreemarker
Lobster Programming
Written by

Lobster Programming

Sharing insights on technical analysis and exchange, making life better through technology.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.