Does Nginx block on file IO?

Justin Cormack justin at
Mon May 2 15:06:41 MSD 2011

On Mon, 2011-05-02 at 07:29 +0200, Piotr Sikora wrote:
> Hi,
> > How is it even related? There is a difference between getting a file
> > from disk and serving it to the client from buffer. You can get it
> > really fast and block for a very little time but than send it to the
> > client very slowly.
> It's actually very related, because with event-driven programming, you're 
> blocking _all_ worker's clients on the single disk I/O.

If you expect file IO to block, use more nginx processes than cores. I
dont think that async IO on Linux is really worth using, although I will
do some benchmarks. You might try switching to FreeBSD as well. 

I think that node.js currently uses a thread pool for async IO on Linux
(possibly all platforms, except maybe Windows), with sync IO in the
background. Linux kernel aio was designed for programs like databases
that manage their own buffer caches, not for normal file IO. If you dont
cache the results it will be slow (unless anything has changed recently,
will do some testing).


More information about the nginx mailing list