All workers in 'D' state using sendfile

Maxim Dounin mdounin at
Mon Jun 10 11:57:06 UTC 2013


On Mon, Jun 10, 2013 at 03:38:45PM +0430, Host DL wrote:

> Dear Maxim,
> Thanks for your response,
> I don't think it will help much since all of my files are larger enough
> than 2MB

The "D" state of nginx workers has only one explanation: blocking 
operations on disks.  When serving static files with nginx on 
Linux, this basically means one of the following:

1. opening / stat()'ing files
2. blocking aio reads due to no directio on unaligned reads
3. blocking aio reads due to no directio on small files

Within nginx, you may reduce possibility of (3) using directio 
directive with a smaller value.  Both (1) and (2) are more or less 
unavoidable, but aren't likely to happen, at least with proper OS 

If in doubt, try tracing where worker processes are blocked.  As a 
very first step, ps(1) output should be examined for a wait 
channel column (wchan).

> Regarding AIO problem in linux, do you think using AIO + sendfile together
> on FreeBSD will be better in performance in my case?


Maxim Dounin

More information about the nginx mailing list