<div dir="ltr">Good idea. <div><br></div><div>Do not forget to increase sysctl params like </div><div><div><br></div><div>net.core.somaxconn</div><div>net.core.netdev_max_backlog</div></div><div><br></div><div><br></div><div>
And more faster get socket stats (netstat -an[s] | wc -l)</div><div>cat /proc/net//sockstat<br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/18 Tatsuo Ishii <span dir="ltr">&lt;<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">&gt; Hi pgpool hackers,<br>
&gt;<br>
&gt; I would like to add new parameter &quot;listen_backlog&quot;. This essentially<br>
&gt; same as Apache&#39;s ListenBacklog parameter:<br>
&gt;<br>
&gt; The second parameter of listen(2) system call.<br>
&gt;<br>
&gt; As you might already know, pgpool accepts concurrent connections up to<br>
&gt; num_init_children. Exceeding connections will be queued in kernel&#39;s<br>
&gt; backlog queue. If the queue is long enough to accept a new connection,<br>
&gt; the request from the client will be almost immediately accepted by<br>
&gt; pgpool once existing client disconnects to pgpool. However, if the<br>
&gt; queue is overflowed, the client might retry after 3 seconds or so, and<br>
&gt; user thinks that pgpool&#39;s response is too bad. Or disconnected by<br>
&gt; pgpool with &quot;Connection to database &quot;test&quot; failed: could not connect<br>
&gt; to server: Connection timed out&quot;.<br>
&gt;<br>
&gt; The solution is, making the backlog parameter large enough for such<br>
&gt; possible load. Currently the backlog is calculated by<br>
&gt; num_init_children * 2. But this may not be large enough for certain<br>
&gt; load. For the case, the new proposed parameter can set the listen()&#39;s<br>
&gt; backlog parameter longer than num_init_children * 2.<br>
&gt;<br>
&gt; Here is an experiment I did to illustrate the effect of the<br>
&gt; parameter(script attached).<br>
&gt;<br>
&gt; I started pgpool with num_init_children = 2, and connected to it by<br>
&gt; using 128 forked pgbench.<br>
&gt; Each pgbench executes 100 read only queries.<br>
&gt;<br>
&gt;        pgbench -C -c 1 -n -S test;date)&amp;<br>
&gt;<br>
&gt; The pgpool server is a Linux box running kernel 3.4.68.<br>
&gt;<br>
&gt; Stock pgpool-II 3.3.1, which set the backlog parameter to 4, took 1<br>
&gt; minute and 7 seconds. And some requests failed with &quot;Connection to<br>
&gt; database &quot;test&quot; failed&quot; error.<br>
<br>
</div></div>Please note that you will find something like:<br>
<br>
    2357 times the listen queue of a socket overflowed<br>
<br>
by executing netstat -s in this case.<br>
<div class="im"><br>
&gt; On the other hand if I set the backlog parameter to 1024, it took only<br>
&gt; 15 seconds without any error.<br>
&gt;<br>
&gt; Opinions?<br>
&gt; --<br>
&gt; Tatsuo Ishii<br>
&gt; SRA OSS, Inc. Japan<br>
&gt; English: <a href="http://www.sraoss.co.jp/index_en.php" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
&gt; Japanese: <a href="http://www.sraoss.co.jp" target="_blank">http://www.sraoss.co.jp</a><br>
</div>_______________________________________________<br>
pgpool-hackers mailing list<br>
<a href="mailto:pgpool-hackers@pgpool.net">pgpool-hackers@pgpool.net</a><br>
<a href="http://www.pgpool.net/mailman/listinfo/pgpool-hackers" target="_blank">http://www.pgpool.net/mailman/listinfo/pgpool-hackers</a><br>
</blockquote></div><br></div>