<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">Hi<br><br>3,9 and 27 seconds sounds like tcp retransmission timeouts<br><a href="http://my.opera.com/cstrep/blog/2011/07/23/how-to-detect-tcp-retransmit-timeouts-in-your-network" target="_blank">http://my.opera.com/cstrep/<wbr>blog/2011/07/23/how-to-detect-<wbr><span class="il">tcp</span>-retransmit-timeouts-in-<wbr>your-network</a><br><br>It sounds like the tcp listen backlog queue is too small and <br>syn packets incoming from the client are dropped<br><br>You can set max for all TCP sockets by configuring sysctl file<br>net.ipv4.tcp_max_syn_backlog = 10000<br><br>And to add to Nginx configuration  (Nginx default value is 511)<br><br>
<pre>listen  80  default  backlog=10000;</pre>
<br>I hope it helps.<br><br>Hagai Avrahami<br><pre><br>I hope it helps.<br><br><br></pre><br><br><br><div><span><br></span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;">  <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> liangrubo <nginx-forum@nginx.us><br> <b><span style="font-weight: bold;">To:</span></b> nginx@nginx.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Tuesday, August 21, 2012 10:23 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: Tuning workers and connections<br> </font> </div> <br>Hello, we meet similar problem.<br><br>if we set "multi_accept off;" and "accept_mutex on;", it sometimes took
 3 or<br>9 or even 21 seconds to connect to nginx on port 80 from the same server. if<br>we set "multi_accept on;" and "accept_mutex off;",  we can connect to nginx<br>on port 80 instantly but it may take long to get the response (more than 3<br>seconds for small css files on the same server).<br><br>Our deploy structure is as follows:<br>frontend nginx listen on port 80, servering static files. For dynamic<br>requests, nginx on port 80 reverse proxy to nginx on port 81 via tcp socket,<br>nginx on port 81 again reverse proxy to uwsgi via unix sokcet.<br><br>the site is handling about 1200 requests per second.<br><br>the server has 24 cpu cores and 96G memory.  the system has low load, lots<br>of free memory and no IO bottleneck.<br><br>some of the nginx configurations are as follows:<br>worker_processes 8; //it was originally 4, I doubled it but it didn't help<br>worker_rlimit_nofile 15240;<br>worker_connections  15240;<br><br>use
 epoll;<br><br>we have keepalive setup for upstream(80 to 81 reverse proxy) as follows:<br>keepalive 32;<br><br><br>information shown by status_sub:<br>Active connections: 4320 <br>server accepts handled requests<br> 9012300 9012300 37349248 <br>Reading: 118 Writing: 199 Waiting: 4003 <br><br>we examined the dynamic request handling is fast and even if it was slow, it<br>should not affect static file servering on port 80 anyway, right?<br><br>it seems nginx can't process the request fast enough but we can't find what<br>is the bottleneck.<br><br>any help is greatly appreciated.<br><br>Posted at Nginx Forum: <a href="http://forum.nginx.org/read.php?2,3638,229939#msg-229939" target="_blank">http://forum.nginx.org/read.php?2,3638,229939#msg-229939</a><br><br>_______________________________________________<br>nginx mailing list<br><a ymailto="mailto:nginx@nginx.org" href="mailto:nginx@nginx.org">nginx@nginx.org</a><br><a
 href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br><br><br> </div> </div> </blockquote></div>   </div></body></html>