📜 ⬆️ ⬇️

Give statics nginx'om

Starting with version 0.8.11, nginx has a new feature for distributing statics - using AIO (Asyncronous Input-Output - non-blocking I / O) for Linux and FreeBSD.

What is this event significant? Up to this point, nginx used the non-blocking mode only when working with the network - any work with files blocked the workflow. What did it lead to? If you have a lot of different content, which is not all in the OS cache (photohosting, etc) - then sooner or later all 50, 150, 200 processes will wait for disk operations and will not be able to serve the new client - even if the content you need can be given from the file cache or request from the backend.


How to deal with this before?
')

Now there is a new way, using a small number of workflows, to distribute everything in non-blocking mode. Testing will emulate the load on file / image hosting - returning a large number of relatively small files. The disk at the same time rests on the speed of seek seek.

Testing method:

image
image

Conclusions: judging by the fact that AIO was able to achieve 300 rps, which significantly exceeds the seek rate for the disks used, the FreeBSD kernel can reorder requests through AIO internally, which gives a significant gain in the absence of a smart raid controller with a large cache. When using the same traditional method - a large number of workflows, if they all go to disk, affect the performance only negatively.

PS: a few comments on the method. The speed of generating random file names is sufficient, adds <0.5 ms to the request (there was no need to measure more precisely, this speed could not be achieved). Perhaps in the tests with aio on a large number of streams, the ceiling of the channel was reached. The time of each test is two minutes.

PPS: AIO's work on Linux has not been tested, results may vary in any direction.

Source: https://habr.com/ru/post/67738/


All Articles