SynologyRS
Performance

Tuning nginx for a small VPS

📅 2025-01-04✎ 7 min read

worker settings, keepalive, gzip and caching that move the needle.

nginx is already fast; tuning it is mostly about not leaving obvious gains on the table and not over-tuning for a box that serves a handful of static pages. A few settings matter, most do not.

worker_processes and connections

worker_processes auto;          # 1 core -> 1 worker, that's it
worker_connections 512;           # plenty for static content

Set workers to auto and stop worrying. The thing that usually matters more than worker count is keepalive connections — it stops clients from handshaking TCP and TLS on every request.

Keepalive

keepalive_timeout 65;
keepalive_requests 1000;
# upstream block if you proxy to an app
upstream backend { server 127.0.0.1:8080; keepalive 32; }

gzip and caching

Compress text, cache the immutable assets for a long time, and version your filenames so the cache header is honest. This is where a static site wins most of its load-time battles.

Stop here unless you are under real load

Buffers, multi_accept, and the rest are for when your metrics tell you a specific thing is wrong. Guessing at them on a quiet box just adds config you cannot explain.

The best nginx tuning is the setting you added because a number told you to, not because a blog said so.