Boost Nginx Throughput 3×: 5 Essential Performance Tuning Parameters
This article explains how to dramatically improve Nginx performance in high‑concurrency scenarios by configuring five crucial parameters—worker_processes, worker_connections, epoll, sendfile/TCP optimizations, and keepalive—complete with code examples and expected impact.
Nginx is a core component of large‑scale architectures, and its performance often becomes the first bottleneck under high concurrency.
Five Key Tuning Parameters
worker_processes : Utilizes multiple CPU cores. Set to the number of cores, e.g., worker_processes auto; This raises CPU utilization from ~20% to 90% and increases throughput by about 1.5×.
worker_connections : Increases the maximum concurrent connections per worker. Example configuration:
events {
worker_connections 65535;
}The theoretical maximum connections equal worker_processes * worker_connections. Adjust ulimit -n accordingly to avoid "Too many open files" errors, yielding a ten‑fold increase in concurrent connections.
epoll : Enables Linux's high‑performance I/O multiplexing. Add to the events block:
events {
use epoll;
}Compared to select/poll (O(n)), epoll operates in O(1), cutting CPU usage by ~50% and reducing latency under heavy load.
sendfile & TCP optimizations : Zero‑copy file transmission and TCP tweaks improve I/O throughput.
sendfile on;
tcp_nopush on;
tcp_nodelay on;These settings boost file transfer performance by ~30% and lower latency by ~15%.
keepalive optimization : Adjusts idle connection timeout and request limit.
keepalive_timeout 30s;
keepalive_requests 1000;Shortening idle time frees resources, while increasing request count per connection reduces handshake overhead.
Applying these configurations can increase overall Nginx throughput by more than 300% in typical high‑traffic environments.
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.
Mike Chen's Internet Architecture
Over ten years of BAT architecture experience, shared generously!
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.
