Boost Nginx Concurrency: Key Settings and Practical Configurations

This guide explains how to maximize Nginx concurrency by configuring worker_processes, worker_connections, keepalive_timeout, and high‑performance I/O options such as sendfile, tcp_nopush, and tcp_nodelay, including formulae, example calculations, recommended values, and system‑level considerations.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Boost Nginx Concurrency: Key Settings and Practical Configurations

worker_processes – Upper limit of concurrency

worker_processes defines how many worker processes Nginx can spawn; setting it to auto makes Nginx create one worker per CPU core, maximizing CPU utilization while avoiding excessive context switches.

worker_processes auto;
如何提升Nginx并发性能(4大性能参数)-mikechen
如何提升Nginx并发性能(4大性能参数)-mikechen

worker_connections – Connections per worker

worker_connections specifies the maximum number of simultaneous connections a single worker can handle. The theoretical maximum concurrent connections is calculated as:

max_concurrency = worker_processes * worker_connections;

For example, 8 workers × 10240 connections = 81 920 concurrent connections. A typical recommended setting is: worker_connections 10240; Note: the operating system’s ulimit -n must be increased accordingly, otherwise the setting will not take effect.

如何提升Nginx并发性能(4大性能参数)-mikechen
如何提升Nginx并发性能(4大性能参数)-mikechen

keepalive_timeout – Tuning persistent connections

Long‑lived keep‑alive connections occupy slots, reducing overall concurrency and QPS. Reducing keepalive_timeout frees connections for new clients. A common value is 15 seconds, but for short‑lived traffic (e‑commerce APIs) it can be lowered to 3–10 seconds.

keepalive_timeout 15;
如何提升Nginx并发性能(4大性能参数)-mikechen
如何提升Nginx并发性能(4大性能参数)-mikechen

High‑Performance I/O Trio

These directives are especially useful for serving static assets (images, videos, etc.) at high throughput.

sendfile on;
tcp_nopush on;
tcp_nodelay on;

sendfile enables zero‑copy file transmission, reducing CPU load. tcp_nopush merges small packets to improve throughput. tcp_nodelay disables Nagle’s algorithm, lowering latency for fast‑response services. Combined, they provide high throughput with low latency.

如何提升Nginx并发性能(4大性能参数)-mikechen
如何提升Nginx并发性能(4大性能参数)-mikechen
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.

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.