Apache2::RequestIO sendfile

Apache2::RequestIO sendfile

am 24.11.2010 21:48:59 von mohitanchlia

If I use $r->sendfile($filenam) and the file is always the same then
does mod_perl open and read this file on every execution or is it
cached? I am wondering if it will be better to copy the contents of
file (500bytes) in the perl module instead.

Is there a overhead or chances of running out of file handles if we
use sendfile? Or is there a better way of using senfile that will
ensure minimal overhead?

Re: Apache2::RequestIO sendfile

am 24.11.2010 22:23:59 von torsten.foertsch

On Wednesday, November 24, 2010 21:48:59 Mohit Anchlia wrote:
> If I use $r->sendfile($filenam) and the file is always the same then
> does mod_perl open and read this file on every execution or is it
> cached? I am wondering if it will be better to copy the contents of
> file (500bytes) in the perl module instead.

Sendfile creates a file bucket (AFAIK). That means if you don't have any=20
filter that needs to read the bucket (for instance mod_ssl, mod_deflate) th=
en=20
the copying should be done by the kernel alone.

On the other hand caching in RAM is also fast. I'd benchmark it.

If you implement the RAM caching then don't forget to send a Content-Length=
=20
header. Otherwise Apache would use chunked transfer encoding which is much=
=20
slower. I measured that a few years ago but I don't think things have chang=
ed=20
a lot since then.

> Is there a overhead or chances of running out of file handles if we
> use sendfile? Or is there a better way of using senfile that will
> ensure minimal overhead?

Only once I have run out of file descriptors when I have experimented with =
the=20
worker-MPM with many threads. After increasing ulimit to 10000 descriptors=
=20
that was solved. If you use prefork MPM I think the default limit for open=
=20
files (1024 descriptors on my system) should be by far enough.

Torsten Förtsch

=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net