High Concurrency Solutions: CDN, Read‑Write Separation, NoSQL, and Caching Strategies
This article explains the concept of high concurrency, its key metrics, and presents four practical backend solutions—static/dynamic separation with CDN, read‑write separation using NoSQL and CQRS, various caching techniques, and lightweight read‑optimisation—to improve performance and scalability of distributed systems.
High concurrency is a crucial factor in designing distributed internet systems, referring to the ability of a system to handle many simultaneous requests, measured by response time, throughput, QPS, and concurrent users.
The article focuses on high‑concurrency read scenarios, noting that many developers only consider read‑heavy cases and overlook write‑side challenges, and introduces four main mitigation strategies.
1. Static/Dynamic Separation and CDN : By separating static resources (HTML, CSS, JS, images) from dynamic content and distributing static files through a Content Delivery Network, requests are served from edge nodes close to users, reducing bandwidth pressure and latency.
Traditional static resource delivery suffers from bandwidth bottlenecks, single‑point failures, and slow response due to geographic distance, whereas CDN caches content across multiple locations, performs DNS‑based load balancing, and serves users from the nearest node.
Frontend optimization includes placing static assets on an Nginx static server, leveraging browser caching (HTTP 304), merging and minifying files, and configuring CDN compression.
2. Read‑Write Separation and NoSQL : Database operations are split into read and write paths. Simple CRUD is abstracted into commands (writes) and queries (reads) using the CQRS pattern, which decouples responsibilities, allowing independent scaling of command and query models.
CQRS offers benefits such as separate technology stacks, better traffic isolation, and clearer data flow, but introduces complexity, potential consistency issues, and higher development cost. Three CQRS architectures are described: single‑database, dual‑database, and event‑sourcing, each with its own trade‑offs.
NoSQL databases (document, key‑value, column‑family, graph) provide flexible schemas, horizontal scalability, and high performance for specific workloads; examples include MongoDB, Redis, Cassandra, and Neo4j.
3. Caching : Two main cache types are local (e.g., Guava Cache, Spring MVC cache) and distributed (e.g., Memcached, Redis). The article discusses cache‑related problems such as cache avalanche, penetration, and breakdown, and emphasizes the need for high availability and proper expiration strategies.
Guava Cache inherits ConcurrentHashMap concepts, offering automatic loading, LRU eviction, expiration based on access/write time, and statistics collection.
Memcached uses consistent hashing for client‑side request routing, enabling simple scaling and fault tolerance; it manages memory with slabs and chunks.
Redis is a remote in‑memory database with multiple data structures, replication, persistence, and sharding, supporting use cases like ranking, rate limiting, pub/sub, queues, and caching, with read speeds up to 110 000 ops/s and write speeds up to 80 000 ops/s.
Improving cache hit rate involves pre‑warming, adjusting cache granularity, expanding capacity, and aligning cache strategy with business requirements to reduce backend load.
DevOps
Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.
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.