Boost Nginx Concurrency: Master the 4 Key Performance Parameters

This guide explains how to maximize Nginx concurrency by configuring four key parameters—worker_processes, worker_connections, keepalive_timeout, and keepalive_requests—plus three I/O optimizations (sendfile, tcp_nopush, tcp_nodelay), and discusses related OS tuning for real‑world performance in production.

Architect Chen
Architect Chen
Architect Chen
Boost Nginx Concurrency: Master the 4 Key Performance Parameters

Worker Processes and Connections

The worker_processes directive sets the number of Nginx worker processes. It is usually matched to the number of CPU cores or set to auto so Nginx detects the optimal count automatically. worker_processes auto; The worker_connections directive defines how many simultaneous connections each worker can handle. The product of worker_processes and worker_connections approximates the maximum concurrent connections Nginx can support under ideal conditions. worker_connections 65535; Actual limits are also constrained by operating‑system parameters such as file‑descriptor limits (ulimit) and epoll settings, so OS‑level tuning is required for the theoretical maximum to be reachable.

Nginx performance parameters
Nginx performance parameters

Keep‑Alive Settings

The keepalive_timeout directive controls how long an idle client connection is kept open. A reasonable timeout reuses TCP connections for repeated requests, reducing handshake overhead and improving throughput. keepalive_timeout 65; The keepalive_requests directive sets the maximum number of requests that can be sent over a single keep‑alive connection. The default is 100; increasing it (e.g., to 10000) can further reduce connection churn. keepalive_requests 10000; Timeout values must balance resource consumption against the performance gains from connection reuse; overly long timeouts waste connections, while too short timeouts diminish reuse benefits.

High‑Performance I/O Options

Three common I/O optimizations significantly improve static‑resource delivery and latency: sendfile enables zero‑copy transmission in the kernel, eliminating user‑space data copies. tcp_nopush (or TCP_CORK) merges small packets when sending large files, increasing bandwidth utilization. tcp_nodelay disables Nagle’s algorithm, which is beneficial for low‑latency, small‑packet interactions.

Combining these settings with appropriate worker_processes, worker_connections, and keep‑alive parameters allows Nginx to achieve higher throughput and lower latency across diverse workloads.

Nginx I/O optimization
Nginx I/O optimization
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.

BackendconcurrencyconfigurationPerformance TuningI/O optimizationNginx
Architect Chen
Written by

Architect Chen

Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.

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.