<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Web on Besterry — Linux &amp; DevOps Notes</title><link>https://besterry.com/categories/web/</link><description>Recent content in Web on Besterry — Linux &amp; DevOps Notes</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 05 Mar 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://besterry.com/categories/web/index.xml" rel="self" type="application/rss+xml"/><item><title>nginx Performance Tuning: Practical Notes from Production</title><link>https://besterry.com/posts/nginx-performance-tuning/</link><pubDate>Tue, 05 Mar 2024 00:00:00 +0000</pubDate><guid>https://besterry.com/posts/nginx-performance-tuning/</guid><description>&lt;p&gt;After running nginx on everything from 512 MB VPS instances to multi-socket bare metal, here are the settings I&amp;rsquo;ve found actually matter.&lt;/p&gt;
&lt;h2 id="worker_processes-and-worker_connections"&gt;worker_processes and worker_connections&lt;/h2&gt;
&lt;p&gt;Start with &lt;code&gt;worker_processes auto;&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;worker_processes auto;
worker_rlimit_nofile 65535;
events {
worker_connections 4096;
use epoll;
multi_accept on;
}
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="keepalive-tuning"&gt;Keepalive tuning&lt;/h2&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;http {
keepalive_timeout 30s;
keepalive_requests 1000;
upstream backend {
server 10.0.0.1:8080;
keepalive 32;
}
}
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="buffer-sizes"&gt;Buffer sizes&lt;/h2&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;client_body_buffer_size 128k;
client_max_body_size 50m;
proxy_buffer_size 8k;
proxy_buffers 8 8k;
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="gzip-and-brotli"&gt;gzip and brotli&lt;/h2&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;gzip on;
gzip_comp_level 5;
gzip_types text/plain text/css application/json;
brotli on;
brotli_comp_level 4;
brotli_types text/plain text/css application/json;
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="measurement"&gt;Measurement&lt;/h2&gt;
&lt;p&gt;None of this matters if you don&amp;rsquo;t measure. Install &lt;code&gt;nginx-module-vts&lt;/code&gt; or expose &lt;code&gt;stub_status&lt;/code&gt;, feed metrics to Prometheus, and compare before/after for any changes.&lt;/p&gt;</description></item></channel></rss>