{"id":1056,"date":"2026-09-04T23:19:01","date_gmt":"2026-09-04T23:19:01","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1056"},"modified":"2026-09-21T22:04:34","modified_gmt":"2026-09-21T22:04:34","slug":"vps-nginx-performance-tuning-caching","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/","title":{"rendered":"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The two lines that decide how much concurrency an Nginx instance can physically accept are <code>worker_processes<\/code> and <code>worker_connections<\/code>. Everything else in an Nginx config \u2014 caching, compression, buffers \u2014 only matters once a request has been accepted. If these two are wrong, the box refuses connections while sitting at 15% CPU, and you spend an afternoon blaming the network. This is a sizing exercise, not a copy-paste exercise.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The arithmetic that actually binds you<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx documents the theoretical ceiling as <code>worker_processes * worker_connections<\/code>. That number is almost never what you get. Two corrections matter, and both are in the official docs but routinely ignored:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Reverse proxy connections consume two slots.<\/strong> A proxied request holds one connection to the client and one to the upstream. A <code>worker_connections<\/code> value of 1024 therefore yields roughly 512 proxied requests per worker, not 1024.<\/li>\n<li><strong>Every open file descriptor counts.<\/strong> Connections, log files, upstream sockets, and cached files all draw on the same <code>RLIMIT_NOFILE<\/code> limit. If Nginx hits the limit, you get <code>worker_connections are not enough<\/code> or <code>too many open files<\/code> in the error log \u2014 not a clean 503.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So the real ceiling is <code>min(worker_processes * worker_connections, nofile_limit * worker_processes)<\/code>, with the connection half divided by two if you proxy. On a 2 vCPU VPS with the default <code>nofile<\/code> of 1024, the file descriptor limit binds long before the connection maths does. <a href=\"https:\/\/virtualserversvps.com\/\">Our VPS comparison page<\/a> lists how each plan approaches vCPU allocation, which is the other half of this decision.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setting worker_processes correctly<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx rounds <code>auto<\/code> up to the number of CPUs it can see, not the number it can use. On a container-style VPS that reports eight host cores but enforces a two-core CPU quota, <code>auto<\/code> spawns eight workers that fight each other for 200% of CPU time. Accept events land in whichever worker is scheduled next, so latency jitter climbs even as throughput stays flat.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Confirm what the kernel exposes versus what you actually get\nnproc\ncat \/sys\/fs\/cgroup\/cpu.max          # cgroup v2: \"200000 100000\" means 2 CPUs\nlscpu | grep -E \"^CPU\\(s\\)|Model name\"\n\n# Verify Nginx agrees with you\ntop -H -p $(pgrep -d, nginx | head -1)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The rule: set <code>worker_processes<\/code> to the cgroup CPU quota, capped at 2\u00d7 physical cores. Beyond that you gain connection slots but not throughput, and each worker carries a fixed memory cost. On a 1 GB VPS, Nginx workers are cheap \u2014 a few megabytes each \u2014 so the failure mode is not memory, it is scheduler thrash.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Raising worker_connections without starving the box<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Raise <code>worker_connections<\/code> to 4096\u20138192, then raise the file descriptor limit in three places, because systemd applies its own ceiling on top of the unit&#8217;s limits.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Layer<\/th><th>File \/ directive<\/th><th>Value<\/th><\/tr><\/thead><tbody><tr><td>Kernel<\/td><td><code>fs.file-max<\/code><\/td><td>2097152<\/td><\/tr><tr><td>systemd (per-unit ceiling)<\/td><td><code>DefaultLimitNOFILE<\/code> in <code>\/etc\/systemd\/system.conf<\/code><\/td><td><code>65535:65535<\/code><\/td><\/tr><tr><td>Nginx unit override<\/td><td><code>LimitNOFILE<\/code> in a <code>nginx.service.d\/*.conf<\/code> drop-in<\/td><td><code>65535<\/code><\/td><\/tr><tr><td>Nginx worker<\/td><td><code>worker_rlimit_nofile<\/code><\/td><td><code>65535<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Skip any layer and Nginx silently keeps the older, lower value. After a reload, confirm that <code>cat \/proc\/$(pgrep -o nginx)\/limits | grep 'open files'<\/code> shows your target and not 1024.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Keepalive changes the concurrency you need<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With <code>keepalive_timeout 75<\/code> (the default), an idle browser holds a connection for over a minute. Two thousand visitors with persistent connections can pin thousands of slots while serving almost no traffic. Setting 15\u201320 seconds typically cuts the live connection count by half on a content site, at the cost of slightly more TLS handshakes. For HTTP\/2, connections are multiplexed and count against <code>http2_max_concurrent_streams<\/code> instead.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>worker_processes auto;          # 2 on a 2 vCPU plan\nworker_rlimit_nofile 65535;\n\nevents {\n    worker_connections 4096;\n    multi_accept on;\n    use epoll;\n}\n\nhttp {\n    keepalive_timeout 20;\n    keepalive_requests 1000;\n    reset_timedout_connection on;\n    client_header_timeout 12;\n    send_timeout 10;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Measuring whether it worked<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Do not trust throughput alone. Watch three signals during a load test:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. Active connections and accept queue depth\ncurl -s http:\/\/127.0.0.1:8080\/nginx_status\nss -lnt | grep ':443'      # Recv-Q above 0 means the backlog is overflowing\n\n# 2. Per-worker file descriptor usage\nls \/proc\/$(pgrep -o nginx)\/fd | wc -l\n\n# 3. Errors actually caused by the limits\ngrep -E 'worker_connections|too many open files|accept4\\(\\) failed' \/var\/log\/nginx\/error.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If connection count plateaus and <code>Recv-Q<\/code> starts growing, the kernel accept backlog is full and clients are being dropped before Nginx sees them \u2014 raise <code>net.core.somaxconn<\/code> and the <code>listen backlog<\/code> value too. If errors show up in the log, you have genuinely hit a limit and raised it \u2014 likely a file descriptor ceiling, since each connection also consumes one on the kernel side. If nothing at all changes but latency improves, the win came from fewer connections, not more.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where the tuning stops paying<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Concurrency limits are a gate, not an engine. Once the gate is wide enough, the bottleneck moves to PHP-FPM workers, the database, or disk I\/O \u2014 and no amount of <code>worker_connections<\/code> helps. When you see requests queueing while Nginx sits idle, that is usually the signal to check per-plan CPU and memory ceilings rather than add more config. <a href=\"https:\/\/virtualserversvps.com\/\">See the full specs and pricing<\/a> to confirm what your instance can sustain before tuning further.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The two lines that decide how much concurrency an Nginx instance can physically accept are worker_processes and worker_connections. Everything else in an Nginx config \u2014 caching, compression, buffers \u2014 only&#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-1056","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 worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS - Virtual Servers VPS Blog<\/title>\n<meta name=\"description\" content=\"The two lines that decide how much concurrency an Nginx instance can physically accept are worker_processes and worker_connections. Everything else in an\" \/>\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\/vps-nginx-performance-tuning-caching\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS\" \/>\n<meta property=\"og:description\" content=\"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-04T23:19:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-21T22:04:34+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\/vps-nginx-performance-tuning-caching\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/\",\"name\":\"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-09-04T23:19:01+00:00\",\"dateModified\":\"2026-09-21T22:04:34+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"description\":\"The two lines that decide how much concurrency an Nginx instance can physically accept are worker_processes and worker_connections. Everything else in an\",\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS\"}]},{\"@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 worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS - Virtual Servers VPS Blog","description":"The two lines that decide how much concurrency an Nginx instance can physically accept are worker_processes and worker_connections. Everything else in an","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\/vps-nginx-performance-tuning-caching\/","og_locale":"en_US","og_type":"article","og_title":"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS","og_description":"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS","og_url":"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-09-04T23:19:01+00:00","article_modified_time":"2026-09-21T22:04:34+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\/vps-nginx-performance-tuning-caching\/","url":"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/","name":"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-09-04T23:19:01+00:00","dateModified":"2026-09-21T22:04:34+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"description":"The two lines that decide how much concurrency an Nginx instance can physically accept are worker_processes and worker_connections. Everything else in an","breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/vps-nginx-performance-tuning-caching\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Nginx worker_processes and worker_connections: Sizing Them for a High-Concurrency VPS"}]},{"@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\/1056","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=1056"}],"version-history":[{"count":3,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1056\/revisions"}],"predecessor-version":[{"id":1192,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1056\/revisions\/1192"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}