In the latest versions of nginx (starting from 0.8.11), there is support for asynchronous file I / O. Potentially, this feature is able to eliminate one of the bottlenecks of the web server - complete blocking of the process during file IO.
The problem is that none of the requests that the process worker is already servicing will be processed further until the file operation is completed. In cases with a large number of large files, this could lead to a noticeable slowdown of the work of the worker.
Previously, this problem was solved by increasing the number of worker processes. Now there is an alternative solution. :) However, before including the file AIO, it is worth considering a number of nuances.
')
First, I want to draw your attention that you should not expect a significant increase in performance from new versions. This is only possible with a very specific load - when the same server simultaneously delivers several small static files, and a very large number of large files.
Secondly, file AIO works only on FreeBSD 4.3 and higher, or on Linux, from kernel version 2.6.22 and higher.
Third, AIO in FreeBSD makes sense to include only in versions of FreeBSD-6.4 STABLE, FreeBSD 7, or newer. In earlier versions, when you turn on AIO, the network subsystem starts using Giant Lock, which means that it is impossible to make some other system call at the same time. In other words, we will get almost no benefits from asynchrony.
Finally, when using AIO for Linux, you should also include directio. Also, if I understood everything correctly, in Linux it is not yet possible to use AIO to load data for sendfile, since turning on directio will disable the use of sendfile automatically.
If you still think you need it, AIO turns on very easily. For Linux, the config fragment will look something like this:
aio on; # AIO
directio 512; # O_DIRECT , 512
output_buffers 128 512k; # ,
References:
Description of AIO in the documentation for NginxChangelog