[erlang-questions] fast file sending - erlang & nginx

Morten Krogh mk@REDACTED
Sun Nov 21 21:25:49 CET 2010

Hi Robert

You mean mmap. I don't see how that would help. Either you have the file 
in a memory buffer when the request arrives, like you did in the example 
or you don't.
If you don't, sendfile should be the best call. If mmaping and sending 
on the socket, after getting the request, outperforms sendfile, then 
sendfile doesn't have a reason to exist.
Of course, you could also mmap in advance which is similar to reading 
the file in advance.
You still had a factor of 2 up to nginx, and that then cannot have 
anything to do with
how the files are read, but must have to do with the epoll/kqueue of the 
sockets, or with the speed of the erlang code,  including the parsing of 
the request header.

Do you have an idea of the speed of your header parsing? If you spend 
100 microseconds on that, it will explain part of the remaining 
difference. If you spend 1 microsecond, it is irrelevant.


On 11/21/10 9:00 PM, Roberto Ostinelli wrote:
> 2010/11/21 Morten Krogh<mk@REDACTED>:
>> Hi Robert
>> That was a big speedup. So what you can do, is to read all static files into
>> memory at server startup, and have some notification whenever the
>> directory changes.
> morten,
> thank you for your suggestion, but this is basically setting up a
> cache server, which is not what i want to do here.
> thus, i was trying to understand if the difference with nginx is
> because it uses nmap, or some other reason.
> cheers,
> r.
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED

More information about the erlang-questions mailing list