<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi</div><div><br><blockquote type="cite"><div><blockquote type="cite">From the output you provided it looks like all nginx workers are <br></blockquote>locked out, either doing something or waiting for some system <br>resources. &nbsp;As you can see - all connections accepted by nginx (6 <br>connections which have nginx process listed in pid column) are in <br>CLOSE_WAIT state, and there are other connections to port 80 which <br>are sitting in listen queue. &nbsp;Am I right in the assumption that <br>nginx does not answer any requests?<br></div></blockquote><div><br></div><div>Yes, that's the issue. nginx becomes unresponsive at this point until I restart it.</div><br><blockquote type="cite"><div>Note well: you haven't posted full config you use, so please check <br>yourself for possible loops in it. &nbsp;I've recently posted some <br>patches which take care of several loops which aren't automatically <br>resolved now, see here for patch and example loops:<br><br><a href="http://nginx.org/pipermail/nginx-devel/2010-January/000099.html">http://nginx.org/pipermail/nginx-devel/2010-January/000099.html</a><br><br>It should be trivial to find if it's the cause though, as nginx <br>worker will eat 100% cpu once caught in such loop.<br></div></blockquote><div><br></div><div>I have a monitoring script that detects these situations (wget can't download from localhost with a 20s timeout) and restarts nginx, but before that it captures a netstat -nap, ps and other system metrics. This is an example of what ps shows:</div><div><br></div><div><div>www-data 24610 &nbsp;0.0 &nbsp;0.1 &nbsp; 7476 &nbsp;2452 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp;07:44 &nbsp; 0:00 nginx: worker process</div><div>www-data 24611 &nbsp;0.0 &nbsp;0.1 &nbsp; 7668 &nbsp;2412 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp;07:44 &nbsp; 0:00 nginx: worker process</div><div>www-data 24612 &nbsp;0.0 &nbsp;0.1 &nbsp; 7668 &nbsp;2416 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp;07:44 &nbsp; 0:00 nginx: worker process</div><div>www-data 24613 &nbsp;0.0 &nbsp;0.1 &nbsp; 7736 &nbsp;2624 ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp;07:44 &nbsp; 0:00 nginx: worker process</div><div><br></div><div>And vmstat:</div><div><br></div><div><div>procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----</div><div>&nbsp;r &nbsp;b &nbsp; swpd &nbsp; free &nbsp; buff &nbsp;cache &nbsp; si &nbsp; so &nbsp; &nbsp;bi &nbsp; &nbsp;bo &nbsp; in &nbsp; cs us sy id wa</div><div>&nbsp;2 &nbsp;0 &nbsp; &nbsp;440 157012 181076 1180340 &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; &nbsp; 2 &nbsp; &nbsp;32 &nbsp; 27 &nbsp; 46 &nbsp;2 &nbsp;0 95 &nbsp;0</div><div>&nbsp;0 &nbsp;0 &nbsp; &nbsp;440 156904 181076 1180340 &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; 26 &nbsp; 28 &nbsp;2 &nbsp;0 94 &nbsp;0</div><div>&nbsp;0 &nbsp;0 &nbsp; &nbsp;440 156888 181076 1180348 &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; 13 &nbsp; 24 &nbsp;0 &nbsp;0 100 &nbsp;0</div><div>&nbsp;0 &nbsp;0 &nbsp; &nbsp;440 156888 181076 1180348 &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; &nbsp; 0 &nbsp; &nbsp; 0 &nbsp; 12 &nbsp; 21 &nbsp;0 &nbsp;0 100 &nbsp;0</div><div>&nbsp;0 &nbsp;0 &nbsp; &nbsp;440 156888 181080 1180348 &nbsp; &nbsp;0 &nbsp; &nbsp;0 &nbsp; &nbsp; 0 &nbsp; 128 &nbsp; 22 &nbsp; 34 &nbsp;0 &nbsp;0 99 &nbsp;1</div></div><div><br></div><div>So the nginx processes don't seem to be in a loop, CPU use is negligible.</div></div><br><blockquote type="cite"><div>Note well 2: I've already asked you to try compiling without third <br>party modules and patches and check if you are able to reproduce <br>the problem. &nbsp;It doesn't really make sense to proceed any further <br>without doing this.<br></div></blockquote><div><br></div><div>I have to admit I still haven't tried this, sorry. :) Will try.</div><br><blockquote type="cite"><div>You have to enable debug log (see <br><a href="http://nginx.org/en/docs/debugging_log.html">http://nginx.org/en/docs/debugging_log.html</a>). &nbsp;Then it will be <br>possible to map fd number to the particular request (and it's full <br>logs). &nbsp;Under linux it should be possible to find out fd number of <br>the particular connection via lsof -p &lt;pid-of-nginx-worker&gt;.<br></div></blockquote><div><br></div><div>Will look into this too and get that info on the monitoring script. Can you think of any other system parameter that can be useful to monitor in these cases?</div><div><br></div><div>Thanks a lot Maxim. You're being really helpful. :-)</div></div><div><br></div>Regards<div><br><div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--&nbsp;</div><div>&nbsp;Vicente Aguilar &lt;<a href="mailto:bisente@bisente.com">bisente@bisente.com</a>&gt; |&nbsp;<a href="http://www.bisente.com/">http://www.bisente.com</a></div></div>
</div>
<br></div></body></html>