The nginx HTTP server has a directive named sendfile
, which can tell it to use the Linux sendfile()
system call to do I/O without copying to an intermediate memory buffer. That should increase the I/O rate and reduce memory use. If you are running on a modern Linux system with a modern version of nginx, does it have any disadvantages?
In the past the directive could be problematic, for example on VirtualBox VMs, hence my qualification of modern installations.
To expand on @DanilaVershinin's answer: Nginx documentation recommends it for efficiency, except for large files. What can occur is that large file transfers can block connections overlong. The solution, found at the same link as above, it to use sendfile_max_chunk
. Example:
location /mp3 {
sendfile on;
sendfile_max_chunk 1m; # Limits chunks to 1 Megabytes
}