I was reading the Apache Performance Tuning documentation last night and came across the EnableSendfile directive.
If your OS supports a sendfile(2) system call, make sure you install the release and/or patches needed to enable it. (With Linux, for example, this means using Linux 2.4 or later. For early releases of Solaris 8, you may need to apply a patch.) On systems where it is available, sendfile enables Apache 2 to deliver static content faster and with lower CPU utilization.
This directive controls whether httpd may use the sendfile support from the kernel to transmit file contents to the client. By default, when the handling of a request requires no access to the data within a file -- for example, when delivering a static file -- Apache uses sendfile to deliver the file contents without ever reading the file if the OS supports it.
They express using caution if you're using NFS or if the binary wasn't built on the same machine you're using it on. It's also noted that you can turn it off per directory if you want to use it but disable it for the network mount.
Does anyone use this and is there any measurable performance gain? I'm also wondering what actually defines a 'static' file in this case.
I did set it up on one server last night and so far I see no performance gain in the CPU graphs. The site though is not what I would consider a very high traffic case though.

Comments
I think you might be reading
I think you might be reading old information. Everyone's been using Linux 2.6 for the past 6 years or so. A static file is anything that doesn't require a programming language on the server to generate on the fly. i.e. most CSS/JS/images/Flash. And CPU usage != performance, CPU usage may influence scalability, but you can only really measure performance by benchmarking.
--
Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his
defaults
looks like the defaults for this is to have it turned on
Description: Use the kernel sendfile support to deliver files to the client
Syntax: EnableSendfile On|Off
Default: EnableSendfile On
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Core
Module: core
Compatibility: Available in version 2.0.44 and later
@dalin ... well it does say
@dalin ... well it does say 2.4 or later and it is also in the latest apache 2.2 doc.
i personally know what a static file is, but i'm wondering how apache is qualifying that. i.e. anything that doesn't have a handler?
makes sense now that i probably won't see any cpu gains unless the server was under heavy load. it does say it serves those static files faster though, so that should show up in an ab test perhaps.
... and it is turned on, not wondering how to use it. just wondering if anyone uses it and has measured any performance gains.
Mike Milano
sendfile() is a magical
sendfile() is a magical thing. Without sendfile(), a CPU sending a file to a network card must first load the file (or chunks of it) from the disk into RAM, then read back the file from RAM and send that out to the network card. With sendfile(), it just pipes the bits that compose the file straight from the disk to the network card. I think - think - on some hardware this can happen without going through the CPU first - the bits just fly directly from the disk to the network card - but don't quote me on that.
That being said, its usefulness may be difficult to detect unless your server is seriously taxed; the CPU is doing less work and using less RAM to serve static files leaving it more receptive to dynamic requests. But even for a non-taxed server, there's really no reason to turn it off unless it's breaking things.
The Boise Drupal Guy!