Maxim,<div><br></div><div>Great advice.  Give me 24 hours to test it out.</div><div><br>The specific requests I am doing /test.html and /status do not hit php-fpm and I verified that by turning it off and hitting those URLs for responses.</div>
<div><br></div><div>I do not think CPU is the issue, but I still value the advice and will go through the variables and see if I get improvements.</div><div><br></div><div>Best,<br>Khalid<br><div><br><div class="gmail_quote">
On Mon, Sep 21, 2009 at 1:46 AM, Maxim Dounin <span dir="ltr">&lt;<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</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>
<div class="im"><br>
On Sun, Sep 20, 2009 at 10:47:21PM -0700, Khalid Shaikh wrote:<br>
<br>
&gt; We are using Nginx on this web server.  Look at the # of reading &amp; writing<br>
&gt; requests.  a curl <a href="http://localhost/test.html" target="_blank">http://localhost/test.html</a> can take up to 45 seconds.<br>
&gt; Can anyone help?<br>
&gt;<br>
&gt; Using telnet I can see that basically the Nginx server is taking time to get<br>
&gt; to the TCP connection that I initiated.<br>
&gt;<br>
&gt; This happens only during peak times of the web site.<br>
<br>
</div>Looks like either nginx has no CPU time due to fastcgi sitting on<br>
the same machine, or nginx workers are blocked on disk.  You may find<br>
out actual reason by examining state of nginx worker processes in<br>
top.<br>
<br>
If the problem is CPU time you shuld just add some to nginx, e.g.<br>
by using worker_priority directive.  Reducing load on fastcgi<br>
(e.g. by using fastcgi_cache) may help too.<br>
<br>
If the problem is disk load, you may try the following:<br>
<br>
1. Set sendfile_max_chunk to something like 128k or 256k.  This<br>
should prevent fast clients from blocking nginx in sendfile() for<br>
too long.<br>
<br>
2. Don&#39;t use sendfile at all and use small number of big<br>
output_buffers (e.g. output_buffers 1 256k;).  This should reduce<br>
number of disk accesses (and seeks) at cost of not using<br>
sendfile() - e.g. some additional CPU usage.<br>
<br>
3. If fastcgi returns big responses that are buffered to disk, try<br>
raising fastcgi_buffers and/or setting fastcgi_max_temp_file_size<br>
0;.  This should prevent nginx from going to disk at cost of not<br>
releasing fastcgi connection as early as possible.  Also you<br>
should consider finding the source of such responses and using<br>
X-Accel-Redirect instead if it&#39;s possible.<br>
<br>
4. Consider using aio.  Though aio on Linux isn&#39;t something<br>
generally usable, but it may help anyway.  Note that some bugs may<br>
be still here, it&#39;s expiremental feature.<br>
<font color="#888888"><br>
Maxim Dounin<br>
</font><div><div></div><div class="h5"><br>
&gt;<br>
&gt; Active connections: 8467<br>
&gt; server accepts handled requests<br>
&gt;  380771 380771 835836<br>
&gt; Reading: 75 Writing: 1497 Waiting: 6895<br>
&gt; <a href="http://67.159.60.59/status" target="_blank">http://67.159.60.59/status</a>      45.03 seconds<br>
&gt;<br>
&gt; I&#39;ve attached the nginx.conf<br>
&gt;<br>
&gt; user www-data www-data;<br>
&gt; worker_processes 32;<br>
&gt;<br>
&gt; error_log  /var/www/log/nginx_error.log;<br>
&gt; pid        /var/run/nginx.pid;<br>
&gt;<br>
&gt; events {<br>
&gt;   worker_connections  10024;<br>
&gt; }<br>
&gt;<br>
&gt; http {<br>
&gt;   include       /etc/nginx/mime.types;<br>
&gt;   default_type  application/octet-stream;<br>
&gt;<br>
&gt;   sendfile         on;<br>
&gt;   tcp_nopush       on;<br>
&gt;   tcp_nodelay      on;<br>
&gt;<br>
&gt;   server {<br>
&gt;     listen       80;<br>
&gt;     server_name  <a href="http://xs.to" target="_blank">xs.to</a>;<br>
&gt;     root   /var/www/xs;<br>
&gt;     error_page  404 index.php;<br>
&gt;     error_page   500 502 503 504  index.php;<br>
&gt;     access_log off;<br>
&gt;<br>
&gt;     location / {<br>
&gt;       root   /var/www/xs;<br>
&gt;       index  index.php default.php;<br>
&gt;       rewrite  ^/albums/(.*)$  /albums/showalbum.php?$1?  last;<br>
&gt;       rewrite  ^/community/(.*)$  /community.php?$1?  last;<br>
&gt;       error_page  404 index.php;<br>
&gt;       error_page   500 502 503 504  index.php;<br>
&gt;     }<br>
&gt;<br>
&gt;     location /status {<br>
&gt;       stub_status on;<br>
&gt;       access_log off;<br>
&gt;     }<br>
&gt;<br>
&gt;     location ~ .php$ {<br>
&gt;       fastcgi_pass <a href="http://127.0.0.1:8888" target="_blank">127.0.0.1:8888</a>;<br>
&gt;       fastcgi_index index.php;<br>
&gt;       fastcgi_intercept_errors on;<br>
&gt;       error_page  404 index.php;<br>
&gt;       error_page   500 502 503 504  index.php;<br>
&gt;       fastcgi_param  SCRIPT_FILENAME    /var/www/xs/$fastcgi_script_name;<br>
&gt;       include /etc/nginx/fastcgi_params;<br>
&gt;     }<br>
&gt;<br>
&gt;     location ~* ^.+.(jpg|jpeg|gif|tiff|png|bmp|ico|fav|html)$ {<br>
&gt;       access_log        off;<br>
&gt;       expires           30d;<br>
&gt;     }<br>
&gt;   }<br>
<br>
</div></div></blockquote></div><br></div></div>