Boost Your Server: Master Nginx Performance Tuning Essentials

This article explains key Nginx performance parameters—including worker processes, connection limits, keepalive, gzip compression, and static file transfer optimizations—providing practical configuration examples to maximize concurrency, reduce latency, and improve overall server efficiency.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Boost Your Server: Master Nginx Performance Tuning Essentials

1. worker_processes

Defines how many worker processes Nginx starts; each process handles requests using an event‑driven model. Matching the number of CPU cores avoids CPU contention and context switches. Nginx can auto‑detect cores with worker_processes auto;.

2. worker_connections

Sets the maximum number of simultaneous connections a single worker can open. Increasing this value raises total concurrency; a typical setting is 10240. The theoretical maximum connections equal worker_processes * worker_connections, which may require raising the OS file‑descriptor limit via ulimit -n.

3. Keepalive connections

Enables persistent HTTP connections so a client can send multiple requests over one TCP connection, reducing handshake overhead. Key directives are keepalive_timeout (e.g., 15‑30 s) and keepalive_requests (e.g., 1000). Example:

http {
    keepalive_timeout 20s;
    keepalive_requests 1000;
}

4. Gzip compression

Compresses text‑based responses to save bandwidth and speed up page loads. Enable with gzip on; and set a balanced compression level, e.g., gzip_comp_level 5 or 6. Also configure gzip_min_length 1k and specify MIME types to compress.

http {
    gzip on;
    gzip_comp_level 6;
    gzip_min_length 1k;
    gzip_types text/plain text/css application/json application/javascript;
}

5. Static file transfer optimization

Use sendfile on to let the kernel transfer files directly, achieving zero‑copy. Pair with tcp_nopush on (enabled after sendfile) to combine headers and file data into full packets, improving network efficiency.

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.

optimizationWeb server
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.