<div dir="ltr">I finally figured out why this was happening.<div><br></div><div>Hope this helps someone.</div><div><br></div><div>We were running php-fpm and had the following configuration.</div><div><br></div><div>pm = dynamic<br></div><div>pm.max_children = 166<br></div><div>pm.start_servers = 16<br></div><div>pm.min_spare_servers = 8<br></div><div>pm.max_spare_servers = 16<br></div><div><br></div><div>This was working fine with the usual load.</div><div>But, we found that whenever there was a spike it led to an increase in 503s.</div><div><br></div><div>This was due to start_servers set to 16.</div><div><br></div><div>php-fpm takes a sec to spawn more processes and during that time we see 503s.</div><div><br></div><div>For a high traffic site ( like ours ), we had to set this to </div><div>pm = static</div><div>pm.max_children = 125 </div><div><br></div><div>The above values are kept keeping in mind our RAM.</div><div>These would be different for others.</div><div><br></div><div>Now, we don't see any 503s as the server is prepared to handle more connections.</div><div><br></div><div>Thanks,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 15 Apr 2021 at 14:03, Maninder Singh <<a href="mailto:mandys@gmail.com">mandys@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Apache runs on port 8080 and is not open to the outside world.<div>All requests are routed through varnish but then not all requests are cached.</div><div><br></div><div>I guess in that case, varnish becomes the only client for apache.</div><div>So, I should increase the KeepAliveTimeout.</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 15 Apr 2021 at 13:45, Dridi Boukelmoune <dridi@varni.sh> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Apr 15, 2021 at 7:27 AM Maninder Singh <<a href="mailto:mandys@gmail.com" target="_blank">mandys@gmail.com</a>> wrote:<br>
><br>
> Thank you Dridi.<br>
> This is very helpful.<br>
><br>
> FYI - My apache keepalive is<br>
> KeepAliveTimeout 3<br>
><br>
> You would suggest increasing this to 5-10 ?<br>
<br>
If varnish is httpd´s only client then increase it to 70s. Varnish<br>
will close unused connections after 60s by default, and if it´s really<br>
really busy that gives a 10s window for the actual shutdown to happen.<br>
<br>
If there are other direct clients in front of your httpd server, then<br>
decrease backend_idle_timeout in varnishd to 2s, but then you will<br>
force varnish to establish connections more often. This is already the<br>
case of course, but at least that will reduce the risk of reusing a<br>
closed connection and failing backend fetches for this reason.<br>
<br>
> We had lowered the KeepAliveTimeout as the server is a very busy one and we want to handle many connections.<br>
<br>
I understand, and there´s a good reason to have a low default when you<br>
can´t trust the clients. It boils down to whether your httpd server is<br>
openly accessible to more than just varnish, including potentially<br>
malicious clients.<br>
<br>
Dridi<br>
</blockquote></div>
</blockquote></div>