Designing a Million‑Concurrent Backend: LVS, Nginx, and Spring Cloud Gateway

This article explains how to build a high‑performance, million‑concurrent backend architecture by combining LVS for L4 load balancing, Nginx for L7 routing, and Spring Cloud Gateway as a resilient microservice gateway, covering traffic distribution, gateway responsibilities, and fault‑tolerance mechanisms.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Designing a Million‑Concurrent Backend: LVS, Nginx, and Spring Cloud Gateway

Million‑concurrent traffic is a core challenge for large‑scale architectures; this guide details a design that uses a multi‑layer load‑balancing approach.

Layered Load‑Balancing Design

Access Layer (LVS + Keepalived) : Use LVS (Layer‑4 virtual server) as the first line of defense, leveraging kernel‑mode forwarding for high performance and Keepalived for high availability to quickly distribute massive TCP/UDP connections.

After LVS, deploy Nginx for Layer‑7 load balancing, handling intelligent routing, static content caching, and SSL termination. Separating complex business logic from LVS improves its efficiency.

Gateway Layer : The gateway serves as the unified entry point for all microservices and must provide high performance and elasticity under million‑concurrent load.

Million‑concurrent architecture: LVS+Nginx+SpringCloudGateway
Million‑concurrent architecture: LVS+Nginx+SpringCloudGateway

Load‑Balancing Design

Under million‑concurrent load, a single‑layer load balancer (e.g., pure Nginx) cannot sustain peak traffic. Multi‑layer load balancing distributes network and application pressure.

Million‑concurrent architecture diagram
Million‑concurrent architecture diagram
upstream microservices {
    least_conn;
    server 192.168.1.10:8080 weight=3 max_fails=3 fail_timeout=10s;
    server 192.168.1.11:8080 weight=2;
    keepalive 32;
}
server {
    listen 80;
    location /api/ {
        proxy_pass http://microservices;
        proxy_set_header X-Real-IP $remote_addr;
        health_check interval=3 fails=2 uri=/actuator/health;
    }
}

Microservice Gateway Architecture

The gateway, as the unified entry for microservices, handles authentication, routing, and traffic shaping under million‑concurrent conditions. Spring Cloud Gateway (based on WebFlux and Netty) replaces Zuul, providing authentication, protocol conversion, route aggregation, and unified rate limiting.

Gateway architecture diagram
Gateway architecture diagram

Key points:

High‑concurrency architecture uses the Reactor model and asynchronous processing to avoid thread blocking.

Dynamic routing employs predicates (path/header matching) and filters (rate limiting, logging), integrating Nacos for service discovery and load balancing.

Core functions include JWT/OAuth authentication, gray release based on User‑Agent, and cache‑penetration protection.

Nginx offloads static resources while the gateway focuses on business routing.

Service Resilience

Circuit Breaking : Monitors service call metrics (error rate, latency) and automatically cuts off calls when thresholds are exceeded, preventing cascade failures. Common frameworks: Sentinel, Hystrix.

Rate Limiting and Degradation : Token bucket, leaky bucket, or counter algorithms control request rates to avoid resource exhaustion. Degradation reduces non‑critical functions to lightweight handling or static responses when resources are scarce, ensuring critical paths remain available.

Circuit breaking diagram
Circuit breaking diagram
Rate limiting and degradation diagram
Rate limiting and degradation diagram
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Microservicesload balancinghigh concurrencygatewayLVS
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

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.