<div dir="ltr"><div><div><div>Thanks for co-operation B.R but i've got to know that aio doesn't work well with linux centos and i already used it once with one of our content servers for serving large-files. I noted that after enabling aio, the svctime reduced but %util increased upto 20% using command iostat -x -d 3<br>
<br></div>Regarding gzip compression, i am afraid that our content server is used for large videos serving as well as conversion which consumes 80% of cpu resources and gzip compression would overwhelm the cpus.<br><br></div>
Also trying to figure out that how nginx works with the terms asynchronous and synchronous ?<br><br></div>Best Regards.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 5, 2013 at 11:46 AM, B.R. <span dir="ltr"><<a href="mailto:reallfqq-nginx@yahoo.fr" target="_blank">reallfqq-nginx@yahoo.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Hello,<br></div><div class="gmail_extra">
<br><div class="gmail_quote"><div class="im">On Wed, Jun 5, 2013 at 1:56 AM, shahzaib shahzaib <span dir="ltr"><<a href="mailto:shahzaib.cb@gmail.com" target="_blank">shahzaib.cb@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hello,<br><br></div>       We're using nginx-1.2.8 to stream large files size 1G but found the slow stream with high utilization of harddrive using command "iostat -x -d 3"<br>


<br><div>      Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util<br>
      sdc               0.00   444.00   78.67    7.00 18336.00  3608.00   256.16     3.28   39.17  11.02  94.40<br>      sdb               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00<br>



      sda               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00   0.00   0.00<br><br></div><div>16G Ram<br></div><div>8X CPU E31240<br></div><div>HDD SATA<br></div><div><br></div></div></blockquote>


</div><div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">The best way of serving large files is to use asynchronous transfer to avoid blocking disk requests.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">


To do so, have a look at the <a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#aio" target="_blank">aio</a> directive. The default behavior uses sendfile, which sends file in a synchronous fashion.<br></div>
<div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">

<br>Note 1: On Linux, aio will work for writing requests only if activated alone. To activate asynchronous read requests (which seems coherent to your use case, since you stream files - I understand yo usend them, thus you read them), you need to activate the <a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#directio" target="_blank">directio</a> directive.<br>


</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">Refer to the aio documentaiton (link above) for details.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">


Note 2: Using directio will automatically disable sendfile. If you don't use it, you'll need to deactivate sendfile manually.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">


You might also wanna have a look at your output_buffers (once again see the aio directive documentation) to improve large files buffering.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">


I read around that buffers large enough (>= 4MiB) are usually advised for big files (splitting them in less parts). Maybe you would like to make some tests for your specific use case to find the most appropriate values.<br>


</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">The number of those buffers also have an impact: too much buffers consumes RAM for nothing, whereas too little of them will slow down requests by creating an artificial bottleneck.<br>


</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline"><br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">


<div>Following are the main nginx configuration :-<br>
<br>http {<br>    include       mime.types;<br>    default_type  application/octet-stream;<br>    #tcp_nopush     on;<br>    client_body_buffer_size 128k;<br>    client_header_buffer_size 128k;<br>    client_max_body_size 1200M;<br>



    keepalive_timeout  10;<br>    ignore_invalid_headers on;<br>    client_header_timeout  3m;<br>    client_body_timeout 3m;<br>    send_timeout     3m;<br>    reset_timedout_connection on;<br>    #gzip  on;<br>    access_log off;<br>



    include /usr/local/nginx/conf/vhosts/*;<br><br>}<div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline"></div><br></div></div></blockquote><div><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">


By default, Nginx sets gzip to off. Depending on the content you stream and since you seem to have a nice CPU potential (you didn't provide information on CPU usage, you'll need to see if you have room for gzip compression there), you might wanna activate gzip to reduce the amount of data transferred, thus lowering the transmission time at the cost of a more sollicitated CPU... if your content provides room for a sensible compression efficiency (once again, it depends on your specific use case).<br>


No need for it if the benefit is 1% ;o)<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div><br></div><div><br></div><div>

Would be very thankful If someone could help me with better configuration of nginx to reduce HDD-utilization.<br>
<br></div><div>
Best Regards.. <br></div></div>
<br>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">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></blockquote></div><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">


No other idea.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Hope I helped,</div><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font>
</div></div>
<br>_______________________________________________<br>
nginx mailing list<br>
<a 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></blockquote></div><br></div>