How to Transform a Simple Blog into a Scalable High‑Traffic System
This article walks through turning a basic personal‑blog architecture—single server, MySQL, and Node.js—into a high‑concurrency system by adding Redis caching, Nginx load balancing, horizontal scaling, read‑write splitting, sharding, NewSQL databases, and message‑queue techniques.
Cache
In read‑heavy scenarios such as blogs, news sites, or e‑commerce, the majority of requests are reads while writes are infrequent. Adding a Redis cache—an in‑memory key‑value store that runs as an independent TCP service—dramatically increases read throughput (up to 100 k ops/s) while reducing load on MySQL. The article also warns about cache consistency, cache penetration, and cache avalanche, and mentions Redis Cluster, Codis, and cloud‑provider managed Redis as scaling options.
Load Balancing
After caching, the next bottleneck moves to the business servers. By deploying Nginx as a reverse‑proxy on multiple machines and configuring it to forward client requests to a pool of backend Node.js instances, traffic can be distributed evenly. Horizontal scaling is achieved by adding or removing servers based on load. To avoid stateful routing problems, servers are designed to be stateless, storing all mutable data in the database. For higher layers, Linux Virtual Server (LVS) can be used as a TCP‑level load balancer, with keepalived providing virtual IP failover and DNS‑based round‑robin for additional resilience.
Database Layer
Read‑Write Splitting
Most mainstream databases, including MySQL, support master‑slave replication. The slave can serve read queries while the master handles writes, effectively offloading read traffic. This technique is illustrated with examples such as moving heavy count queries to the slave to free the master for write operations.
Sharding (Database Partitioning)
When a single master becomes a write bottleneck, multiple masters can be introduced. The key challenge is routing each piece of data to the correct shard. Simple modulo hashing (hash(user_id) % db_num) works only for static node counts; in practice, consistent hashing is preferred to minimize data movement during scaling. Middleware such as MyCat can help handle cross‑shard queries, sorting, pagination, and ACID guarantees.
NewSQL
Traditional InnoDB stores data in page‑oriented structures, causing write amplification. Log‑Structured Merge‑Tree (LSM‑Tree) databases such as RocksDB and LevelDB write sequentially, eliminating write amplification. Distributed NewSQL systems like TiDB (built on RocksDB) provide strong consistency, high availability, and easy horizontal scaling via Raft consensus. Other NewSQL solutions mentioned include Hive, Elasticsearch, ClickHouse, and Dgraph, each addressing specific workloads.
Message Queue
Message queues can be used for rate limiting—queueing incoming requests and feeding them to backend servers at a controlled pace—and for asynchronous processing, such as decoupling order creation from downstream actions like shipping notifications. This reduces request latency and smooths traffic spikes.
Summary
Starting from a single‑server, single‑database setup, the article demonstrates a step‑by‑step evolution: add Redis caching, apply read‑write splitting, horizontally scale business servers behind Nginx/LVS, introduce sharding with consistent hashing, and finally adopt a distributed NewSQL database such as TiDB. Together these techniques provide high performance, high consistency, and a clear path toward a fully distributed architecture.
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.
IT Architects Alliance
Discussion and exchange on system, internet, large‑scale distributed, high‑availability, and high‑performance architectures, as well as big data, machine learning, AI, and architecture adjustments with internet technologies. Includes real‑world large‑scale architecture case studies. Open to architects who have ideas and enjoy sharing.
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.
