{"id":870,"date":"2026-08-12T23:05:33","date_gmt":"2026-08-12T23:05:33","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=870"},"modified":"2026-08-12T23:05:33","modified_gmt":"2026-08-12T23:05:33","slug":"nginx-worker-tuning-small-vps","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/","title":{"rendered":"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">On a 1&ndash;2 vCPU, 1&ndash;2 GB VPS, the default nginx configuration wastes memory and lets slow clients tie up workers that should be serving real traffic. The good news: a handful of directives fixes most of the pain, and every change is verifiable with a benchmark. This guide walks through the nginx settings that matter on small servers &mdash; worker processes, timeouts, buffers, and static-file handling &mdash; with concrete values and the reasoning behind them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Worker Processes and Connections<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">nginx runs one worker process per CPU core by design. On a small VPS, set <code>worker_processes auto;<\/code> so nginx matches whatever vCPUs the kernel actually sees &mdash; including your burst allocation. Each worker handles up to <code>worker_connections<\/code> simultaneous connections; 1024 is a sensible ceiling on a 1&ndash;2 GB box. The event loop should look like this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>worker_processes auto;<\/code> &mdash; one worker per vCPU<\/li>\n<li><code>worker_connections 1024;<\/code> &mdash; connections per worker (2048 only if RAM allows)<\/li>\n<li><code>use epoll;<\/code> &mdash; the right event model on Linux<\/li>\n<li><code>multi_accept on;<\/code> &mdash; accept all new connections in one notification<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Memory math is simple: each connection costs a few kilobytes of overhead, and each worker&#8217;s total memory footprint scales with <code>worker_connections<\/code>. On a 1 GB VPS, raising <code>worker_connections<\/code> to 4096 without raising RAM just moves the problem from nginx to the OOM killer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Timeouts That Stop Slow Clients from Hogging Workers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Slow clients &mdash; mobile connections, crawlers, keep-alive hoarders &mdash; occupy a worker for as long as the timeouts allow. Tight, realistic values free workers quickly without hurting legitimate users:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>keepalive_timeout 20;<\/code> &mdash; how long an idle keep-alive connection stays open (20&ndash;30 s is plenty)<\/li>\n<li><code>keepalive_requests 500;<\/code> &mdash; requests per keep-alive connection before recycling<\/li>\n<li><code>client_body_timeout 10;<\/code> &mdash; seconds to read the request body (10&ndash;15 s)<\/li>\n<li><code>client_header_timeout 10;<\/code> &mdash; seconds to read the request headers<\/li>\n<li><code>send_timeout 10;<\/code> &mdash; seconds between two write operations to a client<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These values assume your application responds in well under a second. If your PHP or Node backend regularly takes longer, raise <code>send_timeout<\/code> to 30&ndash;60 s &mdash; but first fix the backend, because timeouts are a symptom, not a solution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Buffers and Request Sizes<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>client_body_buffer_size 16k;<\/code> &mdash; buffer for the request body before spilling to disk<\/li>\n<li><code>client_max_body_size 2m;<\/code> &mdash; maximum upload size; raise it only if your app needs it<\/li>\n<li><code>large_client_header_buffers 4 16k;<\/code> &mdash; headroom for large cookies and long URIs<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Oversized buffers on a small VPS are pure waste &mdash; nginx allocates them per request. Keep them small and let the OS page cache do the heavy lifting.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Static Files and Compression<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For static assets, the classic trio is <code>sendfile on;<\/code> (copy files straight from disk to the socket), <code>tcp_nopush on;<\/code> (send headers and file data in one packet), and <code>tcp_nodelay on;<\/code> (disable Nagle for interactive traffic). Enable gzip for text assets with <code>gzip on;<\/code>, <code>gzip_comp_level 5;<\/code>, <code>gzip_min_length 1024;<\/code>, and <code>gzip_types text\/css application\/javascript application\/json image\/svg+xml;<\/code>. Finally, cache open file metadata so repeated requests skip stat calls: <code>open_file_cache max=1000 inactive=20s;<\/code>, <code>open_file_cache_valid 30s;<\/code>, <code>open_file_cache_min_uses 2;<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Directive<\/th><th>Recommended value<\/th><th>Why it matters<\/th><\/tr><\/thead><tbody><tr><td>worker_processes<\/td><td>auto<\/td><td>Matches workers to actual vCPUs<\/td><\/tr><tr><td>keepalive_timeout<\/td><td>20<\/td><td>Frees workers held by idle connections<\/td><\/tr><tr><td>client_max_body_size<\/td><td>2m<\/td><td>Prevents memory waste on oversized uploads<\/td><\/tr><tr><td>gzip_comp_level<\/td><td>5<\/td><td>Good compression without burning CPU<\/td><\/tr><tr><td>open_file_cache<\/td><td>max=1000 inactive=20s<\/td><td>Cuts stat() syscalls for repeated files<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Small Defaults Worth Changing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A few one-line defaults round out the setup. Set <code>server_tokens off;<\/code> to stop nginx from advertising its version in headers &mdash; a cheap win that also reduces automated exploit attempts. Replace the default combined log format with a minimal one and disable access logging for static assets: <code>location ~* \\.(css|js|png|jpg|svg|woff2)$ { access_log off; expires 7d; }<\/code> keeps disk I\/O and log rotation down on small boxes. If you proxy to PHP-FPM or an upstream app, add <code>upstream php { server unix:\/run\/php\/php-fpm.sock; keepalive 32; }<\/code> and set <code>proxy_http_version 1.1;<\/code> with <code>proxy_set_header Connection \"\";<\/code> so upstream connections are reused instead of re-established per request &mdash; a measurable latency win under concurrent load.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify and Measure<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After editing, validate and reload with <code>nginx -t &amp;&amp; sudo systemctl reload nginx<\/code>. Then benchmark before and after with wrk: <code>wrk -t2 -c50 -d30s http:\/\/localhost\/<\/code>. On a typical small VPS you should see lower p95 latency and a smaller nginx memory footprint after tuning. The changes interact with your PHP-FPM or application settings, so retest after any backend change. Track resident memory too &mdash; <code>ps -o pid,rss,cmd -C nginx<\/code> shows per-worker RSS, and each worker should stay well under 50 MB on a tuned config; if workers creep toward 100 MB, reduce <code>worker_connections<\/code> or trim buffer sizes. If your workload is WordPress-heavy, also look at the <a href=\"https:\/\/virtualserversvps.com\/#features\">caching features compared at virtualserversvps.com<\/a> &mdash; nginx tuning pairs well with FastCGI caching and Redis object caching. The <a href=\"https:\/\/virtualserversvps.com\/#faq\">FAQ<\/a> also answers common questions about running web servers on small plans.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start with the timeouts and buffer sizes &mdash; they are the highest-impact, lowest-risk changes on a small VPS. <a href=\"https:\/\/virtualserversvps.com\/#providers\" rel=\"noreferrer noopener sponsored\">Compare VPS plans sized for nginx and PHP-FPM and deploy your tuned stack today<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On a 1&ndash;2 vCPU, 1&ndash;2 GB VPS, the default nginx configuration wastes memory and lets slow clients tie up workers that should be serving real traffic. The good news: a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-870","post","type-post","status-publish","format-standard","hentry","category-performance-optimization"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter\" \/>\n<meta property=\"og:description\" content=\"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-12T23:05:33+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/\",\"name\":\"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-08-12T23:05:33+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/","og_locale":"en_US","og_type":"article","og_title":"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter","og_description":"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter","og_url":"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-08-12T23:05:33+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/","url":"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/","name":"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-08-12T23:05:33+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/nginx-worker-tuning-small-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Nginx Tuning for a Small VPS: Worker Processes, Buffers, and Timeouts That Matter"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=870"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/870\/revisions"}],"predecessor-version":[{"id":876,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/870\/revisions\/876"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}