Operations 3 min read

Boost Nginx Performance: 5 Essential Settings for Ten‑Fold Throughput

This guide explains how to tune Nginx for maximum performance by leveraging multi‑core CPUs, increasing concurrent connections, enabling zero‑copy file transfer, and optimizing keep‑alive settings, with concrete configuration examples and practical recommendations.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Boost Nginx Performance: 5 Essential Settings for Ten‑Fold Throughput

Utilize Multi‑Core CPUs

Set the worker_processes directive to match the number of CPU cores (or a multiple) to fully exploit parallelism. Too many workers cause excessive context switches; too few waste resources.

worker_processes 4;

Increase Maximum Concurrent Connections

Adjust worker_connections to define how many simultaneous connections each worker can handle. The overall maximum is worker_processes * worker_connections. Choose a value based on server memory and expected traffic, commonly 10240 or higher, while also raising the OS file‑descriptor limit.

worker_connections 10240;

Zero‑Copy and Network Transfer Optimizations

Enable sendfile to use zero‑copy, reducing kernel‑user space copying. Use tcp_nopush to batch headers and data, and tcp_nodelay to disable Nagle’s algorithm for lower latency on small packets.

sendfile on;
tcp_nopush on;
tcp_nodelay on;

Connection Timeout and Keep‑Alive Settings

Configure keepalive_timeout to define how long an idle persistent connection stays open, and keepalive_requests to limit the number of requests per connection. A typical timeout is 30‑60 seconds, balancing reuse benefits against idle resource consumption.

http {
    keepalive_timeout 60s;
    keepalive_requests 1000;
}

Practical Recommendations

Increase keepalive_timeout moderately (e.g., 30‑60 s) to reduce connection‑setup overhead, but avoid excessively long values that tie up server resources. Combine the above settings to achieve noticeable performance gains, often up to ten times higher throughput when properly tuned.

Nginx performance optimization diagram
Nginx performance optimization diagram
backendNginxserver configurationTuning
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.