[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Coroutines and blocking IO
- From: Jon Smirl <jonsmirl@...>
- Date: Thu, 26 Jan 2006 17:36:07 -0500
On 1/26/06, Klaus Ripke <paul-lua@malete.org> wrote:
> right, but see notes on AIO e.g. in http://www.kegel.com/c10k.html
That document has not been updated since 2003. It does not reflect the
current state of Linux 2.6.
> > Think about the problem of a 56K dialup modem asking for a 2MB file
> > from a lua web server. It is going to to take eight minutes to send
> > the file to the modem. Obviously async IO has to be used or the web
> > server will be useless.
> No, async IO (like aio or the win overlapping style) is very rarely used
> in webservers, and many do not even use nonblocking IO but rely on a
> thread or process pool to just do the waiting.
Both Apache and Lighttpd use non-blocking IO via sendfile(). I'm
looking at the source right now. sendfile() in 2.6 definitely works in
non-blocking mode, I have an strace of it happening.
Check out Lighttpd. Lighttd is entirely non-blocking and event driven.
It is not threaded.
http://www.lighttpd.net/
Checking the current 2.6 kernel tree, the file systems that implement
non-blocking IO are: cifs, ext2, ext3, jffs, nfs, ocfs, xfs and pipes.
Of course the level of implementation varies in the file systems but
each offers some non-blocking IO.
> > If you set both the net and disk fd to
> > O_NONBLOCK and then call sendfile() you will get a stream of
> > EAGAIN/epoll events that will allow you to multitask. Apache,
> > lighttpd, etc all do this.
> It is nonblocking on the net end only.
> That's why an aio_sendfile() call is on many whishlists.
--
Jon Smirl
jonsmirl@gmail.com