sendfile to nonblocking socket
Date: Wed Apr 25 2007 - 06:47:28 EST
Answer to Alex Vorona (I'm not subscribed to linux kernel list so CC me).
Serious answers to an almost troll question (no offence here :-).
1) The possibility that sendfiles blocks,
when it has to wait for disk reads / pages,
has been repeatedly mentioned (and thus known) for ages by everybody
(including Linus) since kernel 2.2.x;
if you search the archives (mailing lists, etc.)
or just google "sendfile blocking" you'll find a lot of stuff about this
2) A possible answer, to your implicit request to add real asynchronous
to sendfile, is to wait for the general asynchronous support for all
syscalls (search the kernel archives in the last 3 months).
3) The simplest solution (that works with every OS) is to just pass
a small (*) amount of data to each sendfile() call,
(*) i.e. between 64 KB (very slow disk with DMA disabled)
and 1024 KB (very fast disk).
Of course, if files to be sent are not in page cache and
there are more than 10 - 100 parallel downloads of different files,
you'll see noticeable latencies (because of disk seeks, etc.);
in any case you may want to add a parameter to this nginx thing
to let the tuning of chunk size.
4) As it has already been mentioned by others, there are many good solutions
that can be used right now to allow the required scalability target:
- using threads;
- using asynchronous I/O;
5) If you want to use some other Web Server that just works,
look for the alternatives (including lighttpd or even Apache).
Nick Name: A.D.F.
E-Mail: <adefacc () tin ! it>
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/