<?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>Nginx on 水源一二三</title><link>https://theweidi.net/tags/nginx/</link><description>Recent content in Nginx on 水源一二三</description><generator>Hugo</generator><language>zh-TW</language><lastBuildDate>Fri, 22 Oct 2021 06:51:29 +0000</lastBuildDate><atom:link href="https://theweidi.net/tags/nginx/index.xml" rel="self" type="application/rss+xml"/><item><title>Nginx 新增 keepalive_time 參數</title><link>https://theweidi.net/nginx-adding-keepalive_time/</link><pubDate>Fri, 22 Oct 2021 06:49:44 +0000</pubDate><guid>https://theweidi.net/nginx-adding-keepalive_time/</guid><description>&lt;p&gt;Nginx 在 1.19.10 以後開始支援設定 &lt;code&gt;keepalive_time&lt;/code&gt;，初始值如下：&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-txt" data-lang="txt"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;// https://nginx.org/en/docs/http/ngx_http_core_module.html
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Default: keepalive_requests 1000;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Default: keepalive_time 1h;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Default: keepalive_timeout 75s;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;// https://nginx.org/en/docs/http/ngx_http_upstream_module.html
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Default: keepalive_requests 1000;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Default: keepalive_time 1h;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Default: keepalive_timeout 60s;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;keepalive_time&lt;/code&gt; 限制了 total connection lifetime，如這個 &lt;a href="https://github.com/nginx/nginx/commit/d9996d6f27150bfb9c9c00d77fac940712aa1d28"&gt;commit&lt;/a&gt; 所說明。&lt;/p&gt;
&lt;p&gt;在原先的設定裡面，其實 keepalive connection 也不是無限久，理論上最多就是 &lt;code&gt;keepalive_requests * keepalive_timeout&lt;/code&gt; 的時間。 &lt;del&gt;是說 75000s 將近 21h 但 &lt;code&gt;keepalive_time&lt;/code&gt; default 卻是 1h 會不會有點太短。&lt;/del&gt;&lt;/p&gt;</description></item></channel></rss>