Hi Maxim,<br><br>Thanks for your reply and sorry for the delay in responding!<br><br>I've applied your suggested changes to three servers in the cluster - hopefully that will give me an accurate idea of their effectiveness. I'll report back when I have more useful info.<br>
<br><br>Thanks again,<br><br>Drew<br>
<br><br><div class="gmail_quote">On Sat, May 12, 2012 at 9:18 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">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 Sat, May 12, 2012 at 08:28:14PM +1000, Drew Wareham wrote:<br>
<br>
> Hello,<br>
><br>
> I have tried to summarize this as much as possible but it's still a lot of<br>
> text. I apologize but wanted to make sure that I provide enough<br>
> information to explain the issue properly.<br>
><br>
> I'm hoping that somebody that uses nginx as a high traffic/concurrency<br>
> download server will be able to shed some light on this issue. I've tried<br>
> as many things as I can think of and everything keeps pointing to it being<br>
> an issue with nginx, not the server - but I am of course more than willing<br>
> to try any suggestions provided.<br>
><br>
</div>> *Background:*<br>
<div class="im">> Approx. 1,500 - 5,000 concurrent connections (peak / off-peak),<br>
> Files vary in size from 5MB to 2GB,<br>
> All downloads; only very small dynamic content scripts run on these servers<br>
> and none take more than 1-3 seconds,<br>
> File are hosted on direct-attached AoE storage with a dedicated 10GE link,<br>
> Server is running nginx-1.0.11, php-fpm 5.3 and CentOS 5.8x64<br>
> (2.6.18-308.4.1.el5.centos.plus).<br>
> Specs are: Dual Xeon E5649 (6 Core), 32GB RAM, 300GB 10k SAS HDD, AoE DAS<br>
> over 10GE<br>
> Download speeds are restricted by the PHP handoff using X-Accel-Redirect,<br>
> but obviously not when I'm testing ;)<br>
><br>
</div>> *Issue:*<br>
<div class="im">> After running for a short, but random period of time (5min ~ 90min) all<br>
> nginx workers will eventually end up in a 'D' state according to ps/top.<br>
> This causes all downloads to run extremely slowly (~25kb/s) but it doesn't<br>
> seem to be caused by I/O because an scp of the same file will complete at<br>
> the expected speed of ~750MB+/s.<br>
><br>
> I usually run with worker_processes set to 13, but I've had to raise this<br>
> to 50 to prevent the issue. This works short term, but I'm guessing<br>
> eventually I will need to restart nginx to fix it.<br>
><br>
</div>> *Config:*<br>
<div class="im">> I'm using sendfile with epoll, and using the following events / http<br>
> settings (I've removed the location block with the fastcgi handler, etc):<br>
<br>
</div>With rotational disks you have to optimize iops to minimize seeks.<br>
This includes:<br>
<br>
1. Switch off sendfile, it works bad on such workloads under linux<br>
due to no ability to control readahead (and hence blocks read from<br>
disk).<br>
<br>
2. Use large output buffers, something like<br>
<br>
output_buffers 1 512k<br>
<br>
would be a good starting point.<br>
<br>
3. Try using aio to ensure better disk concurrency (and note under<br>
linux it needs directio as well), i.e. something like this<br>
<br>
aio on;<br>
directio 512;<br>
<br>
(this will require newer kernel though, but using 2.6.18 nowadays<br>
looks like bad idea, at least if you need speed)<br>
<br>
4. Try tuning io scheduler, there have been reports that deadline<br>
might be better for such workloads.<br>
<br>
More details can be found here:<br>
<br>
<a href="http://nginx.org/r/output_buffers" target="_blank">http://nginx.org/r/output_buffers</a><br>
<a href="http://nginx.org/r/aio" target="_blank">http://nginx.org/r/aio</a><br>
<a href="http://nginx.org/r/directio" target="_blank">http://nginx.org/r/directio</a><br>
<br>
Maxim Dounin<br>
<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>