I have been looking at this issue to try to understand the interactions and this is what I have found out so far.<div><div><br></div><div>I can reproduce the issue by decreasing the&nbsp;<span class="Apple-style-span" style="border-collapse: collapse; ">net.ipv4.tcp_max_syn_backlog and&nbsp;&nbsp;setting net.ipv4.tcp_syncookies = 0. &nbsp;It makes sense that when the load gets a little high the system does not process the accept fast enough and the backlog builds up. &nbsp;When the backlog fills up the ACK to the initial SYN is not issued.&nbsp;</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; ">It would seem also that enabling syncookies uses some other mechanism as I do not see the dropped connections when I have &nbsp;net.ipv4.tcp_syncookies = 1 and back log to some small value like&nbsp;net.ipv4.tcp_max_syn_backlog =10. &nbsp;From what I read so far is that syncookies goes into action when you hit a certain high water mark on your backlog buffer. &nbsp;Raising the backlog value and/or enabling syncookies seems like a good idea.&nbsp;</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse;">You can look at how many connection are in the backlog with net stat.</span></div><div><div>netstat -aln | grep -c SYN_RECV</div><div>146</div><div>The problem here is that this gives you and instantaneous count of the backlog. &nbsp;As you can imagine this backlog is getting filled and cleared at a high rate. It would be nice to know when this actually gets full or even what the max has been over a period of time. &nbsp;Is there a stat like this in net statistics?</div>
<div>This information seems like it is quite important in determining the performance of your server latency. &nbsp;</div><div><br></div><div>In nginx there is the optional backlog variable in the listen configuration. &nbsp;I imagine that this maps directly to the system call listen. &nbsp;Though I see that the nginx backlog default is -1. How does that translate to the system parameter which requires an in above 0.</div>
<div><br></div><div><br></div><div>Radek</div></div><div><br></div><div><br><br><div class="gmail_quote">On Wed, Feb 4, 2009 at 12:29 AM, Olivier B. <span dir="ltr">&lt;<a href="mailto:nginx.list@daevel.fr">nginx.list@daevel.fr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello,<br>
<br>
have you tried to disable syncookies and/or adjust them ?<br>
On the varnish documentation ( <a href="http://varnish.projects.linpro.no/wiki/Performance" target="_blank">http://varnish.projects.linpro.no/wiki/Performance</a> ) there is at least this setup (in /etc/sysctl.conf) :<br>

<br>
 &nbsp; net.ipv4.tcp_syncookies = 0<br>
 &nbsp; net.ipv4.tcp_max_orphans = 262144<br>
 &nbsp; net.ipv4.tcp_max_syn_backlog = 262144<br>
 &nbsp; net.ipv4.tcp_synack_retries = 2<br>
 &nbsp; net.ipv4.tcp_syn_retries = 2<br>
<br>
<br>
and what about netfilter connection tracking ?<br>
<br>
Olivier<br>
<br>
Radek Burkat a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="Ih2E3d">
Thanks Igor, for eliminating one variable for me. I noticed that when I use a single worker and set the affinity to the same core as the ethernet interface interrupt I decrease the frequency of the issue but do not eliminate it. &nbsp;Not sure <br>

Are there any kernel/network debugging tools which reach a little deeper than tcpdump?<br>
<br>
Radek<br>
<br></div><div><div></div><div class="Wj3C7c">
On Tue, Feb 3, 2009 at 10:11 PM, Igor Sysoev &lt;<a href="mailto:is@rambler-co.ru" target="_blank">is@rambler-co.ru</a> &lt;mailto:<a href="mailto:is@rambler-co.ru" target="_blank">is@rambler-co.ru</a>&gt;&gt; wrote:<br>

<br>
 &nbsp; &nbsp;On Tue, Feb 03, 2009 at 10:07:27PM -0800, Radek Burkat wrote:<br>
<br>
 &nbsp; &nbsp;&gt; Have a machine running the latest devel version nginx-0.7.33<br>
 &nbsp; &nbsp;(tried 0.6.35<br>
 &nbsp; &nbsp;&gt; with same results) for serving small (less than 10K images) and<br>
 &nbsp; &nbsp;am seeing on<br>
 &nbsp; &nbsp;&gt; tcpdump that some SYN packets are not responded to right<br>
 &nbsp; &nbsp;away.The browser<br>
 &nbsp; &nbsp;&gt; does retransmit these image requests every second and on the 2nd<br>
 &nbsp; &nbsp;or 3rd<br>
 &nbsp; &nbsp;&gt; resent SYN, I finally start seeing and ACK, and the images load.<br>
 &nbsp; &nbsp;&gt; It is very indeterministic as to when it happens and can only<br>
 &nbsp; &nbsp;reproduce it<br>
 &nbsp; &nbsp;&gt; some of the time. &nbsp;When it does occur the outcome is a page with<br>
 &nbsp; &nbsp;some images<br>
 &nbsp; &nbsp;&gt; loaded and others (whose SYN packets are not ACKs) are not<br>
 &nbsp; &nbsp;loaded.....a few<br>
 &nbsp; &nbsp;&gt; seconds later they load.<br>
 &nbsp; &nbsp;&gt; Typically the system has ~2000 active connections, most in keep<br>
 &nbsp; &nbsp;alive. &nbsp;The<br>
 &nbsp; &nbsp;&gt; load is around 100-200 req/sec.<br>
 &nbsp; &nbsp;&gt;<br>
 &nbsp; &nbsp;&gt; I have tries all sorts of settings and configurations suggested<br>
 &nbsp; &nbsp;in the<br>
 &nbsp; &nbsp;&gt; maillist but I still dont have the solution for this issue.<br>
 &nbsp; &nbsp; from 1 to 4<br>
 &nbsp; &nbsp;&gt; workers, changing the connection counts, different even<br>
 &nbsp; &nbsp;handlers, kernel<br>
 &nbsp; &nbsp;&gt; buffers, etc.<br>
 &nbsp; &nbsp;&gt; It just seems so anecdotal to just change a bunch of settings<br>
 &nbsp; &nbsp;without being<br>
 &nbsp; &nbsp;&gt; able to what is happening internally.<br>
 &nbsp; &nbsp;&gt; I&#39;d like to be able to debug a little deeper to find out what is<br>
 &nbsp; &nbsp;happening<br>
 &nbsp; &nbsp;&gt; to these packets.<br>
 &nbsp; &nbsp;&gt;<br>
 &nbsp; &nbsp;&gt; How would I go about debugging what is the cause of it. &nbsp;Is it<br>
 &nbsp; &nbsp;the interface<br>
 &nbsp; &nbsp;&gt; driver, kernel, or nginx? &nbsp;What kind of tools and debugging<br>
 &nbsp; &nbsp;options can I<br>
 &nbsp; &nbsp;&gt; try next?<br>
<br>
 &nbsp; &nbsp;nginx has not any relation to TCP handshake (SYN, SYN/ACK, ACK),<br>
 &nbsp; &nbsp;this is kernel or driver issue.<br>
<br>
 &nbsp; &nbsp;&gt; Thanks, Radek<br>
 &nbsp; &nbsp;&gt;<br>
 &nbsp; &nbsp;&gt;<br>
 &nbsp; &nbsp;&gt; System Details<br>
 &nbsp; &nbsp;&gt; model name : Intel(R) Xeon(R) CPU X3210 @ 2.13GHz<br>
 &nbsp; &nbsp;&gt; Linux n06 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 12:03:43 EST 2008<br>
 &nbsp; &nbsp;i686 i686<br>
 &nbsp; &nbsp;&gt; i386 GNU/Linux<br>
 &nbsp; &nbsp;&gt; eth0<br>
 &nbsp; &nbsp;&gt; Advertised auto-negotiation: Yes<br>
 &nbsp; &nbsp;&gt; Speed: 1000Mb/s<br>
 &nbsp; &nbsp;&gt; Duplex: Full<br>
 &nbsp; &nbsp;&gt; Port: Twisted Pair<br>
 &nbsp; &nbsp;&gt; PHYAD: 1<br>
 &nbsp; &nbsp;&gt; Transceiver: internal<br>
 &nbsp; &nbsp;&gt; Auto-negotiation: on<br>
 &nbsp; &nbsp;&gt; Supports Wake-on: g<br>
 &nbsp; &nbsp;&gt; Wake-on: d<br>
 &nbsp; &nbsp;&gt; Current message level: 0x000000ff (255)<br>
 &nbsp; &nbsp;&gt; Link detected: yes<br>
 &nbsp; &nbsp;&gt; driver: tg3<br>
 &nbsp; &nbsp;&gt; version: 3.86<br>
 &nbsp; &nbsp;&gt; firmware-version: 5721-v3.61, ASFIPMI v6.21<br>
 &nbsp; &nbsp;&gt; bus-info: 0000:05:00.0<br>
 &nbsp; &nbsp;&gt;<br>
 &nbsp; &nbsp;&gt; avg-cpu: %user %nice %system %iowait %steal %idle<br>
 &nbsp; &nbsp;&gt; 0.10 0.00 0.20 2.43 0.00 97.27<br>
 &nbsp; &nbsp;&gt; Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz<br>
 &nbsp; &nbsp;await svctm<br>
 &nbsp; &nbsp;&gt; %util<br>
 &nbsp; &nbsp;&gt; sda 0.00 0.00 27.40 0.00 443.20 0.00 16.18 0.10 3.50 3.32 9.10<br>
 &nbsp; &nbsp;&gt; no overruns or errors on interface.<br>
<br>
 &nbsp; &nbsp;--<br>
 &nbsp; &nbsp;Igor Sysoev<br>
 &nbsp; &nbsp;<a href="http://sysoev.ru/en/" target="_blank">http://sysoev.ru/en/</a><br>
<br>
<br>
</div></div></blockquote>
<br>
<br>
</blockquote></div><br></div></div>