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"><<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>></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>
> We are using Nginx on this web server. Look at the # of reading & writing<br>
> requests. a curl <a href="http://localhost/test.html" target="_blank">http://localhost/test.html</a> can take up to 45 seconds.<br>
> Can anyone help?<br>
><br>
> Using telnet I can see that basically the Nginx server is taking time to get<br>
> to the TCP connection that I initiated.<br>
><br>
> 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'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's possible.<br>
<br>
4. Consider using aio. Though aio on Linux isn't something<br>
generally usable, but it may help anyway. Note that some bugs may<br>
be still here, it's expiremental feature.<br>
<font color="#888888"><br>
Maxim Dounin<br>
</font><div><div></div><div class="h5"><br>
><br>
> Active connections: 8467<br>
> server accepts handled requests<br>
> 380771 380771 835836<br>
> Reading: 75 Writing: 1497 Waiting: 6895<br>
> <a href="http://67.159.60.59/status" target="_blank">http://67.159.60.59/status</a> 45.03 seconds<br>
><br>
> I've attached the nginx.conf<br>
><br>
> user www-data www-data;<br>
> worker_processes 32;<br>
><br>
> error_log /var/www/log/nginx_error.log;<br>
> pid /var/run/nginx.pid;<br>
><br>
> events {<br>
> worker_connections 10024;<br>
> }<br>
><br>
> http {<br>
> include /etc/nginx/mime.types;<br>
> default_type application/octet-stream;<br>
><br>
> sendfile on;<br>
> tcp_nopush on;<br>
> tcp_nodelay on;<br>
><br>
> server {<br>
> listen 80;<br>
> server_name <a href="http://xs.to" target="_blank">xs.to</a>;<br>
> root /var/www/xs;<br>
> error_page 404 index.php;<br>
> error_page 500 502 503 504 index.php;<br>
> access_log off;<br>
><br>
> location / {<br>
> root /var/www/xs;<br>
> index index.php default.php;<br>
> rewrite ^/albums/(.*)$ /albums/showalbum.php?$1? last;<br>
> rewrite ^/community/(.*)$ /community.php?$1? last;<br>
> error_page 404 index.php;<br>
> error_page 500 502 503 504 index.php;<br>
> }<br>
><br>
> location /status {<br>
> stub_status on;<br>
> access_log off;<br>
> }<br>
><br>
> location ~ .php$ {<br>
> fastcgi_pass <a href="http://127.0.0.1:8888" target="_blank">127.0.0.1:8888</a>;<br>
> fastcgi_index index.php;<br>
> fastcgi_intercept_errors on;<br>
> error_page 404 index.php;<br>
> error_page 500 502 503 504 index.php;<br>
> fastcgi_param SCRIPT_FILENAME /var/www/xs/$fastcgi_script_name;<br>
> include /etc/nginx/fastcgi_params;<br>
> }<br>
><br>
> location ~* ^.+.(jpg|jpeg|gif|tiff|png|bmp|ico|fav|html)$ {<br>
> access_log off;<br>
> expires 30d;<br>
> }<br>
> }<br>
<br>
</div></div></blockquote></div><br></div></div>