The default config file shipped with NGINX (and Fedora) has sendfile on
option, but upon further reading, it seems the option by itself is not a good idea, since sending large files would block the worker process? What other options should be used? Currently I see sendfile_max_chunk
, aio
, directio
, but should they be used?
Here says sendfile_max_chunk
, which has a default value 2m. I guess this is why the config only has the sendfile line.
This answer and the doc says aio
to make sendfile non-blocking. The doc says the option is to pre-load file into memory. A bit opposite to sendfile? But perhaps just for FreeBSD, the doc for aio says sendfile is disabled for bigger files.
This article and the doc for aio also suggest configuring thread pool for multi-threading so the blocking does not affect the worker process.
The doc for aio also says directio
must be enabled for aio on Linux. However this quote says memory cache will be disabled, which isn’t optimal.
Finally, the NGINX article I linked says none of these is needed if RAM is big enough. Does that include sendfile
?
I’m a bit confused, the options started as nice to have or needed, but the more I read about them, the more they seem to be situational.