In Nginx, which scenarios are suitable for enabling sendfile and direo o?

Source: Internet
Author: User
Tags sendfile
In Nginx, what scenarios are suitable for enabling sendfile, what scenarios are suitable for enabling directio in Nginx, what scenarios are suitable for enabling sendfile, And what scenarios are suitable for enabling directio?

Reply content:

In Nginx, which scenarios are suitable for enabling sendfile and direo o?

Http://nginx.org/en/docs/http/ngx_http_core_module.html#aio

Location/video/{sendfile on; sendfile_max_chunk 256 k; aio threads; directio 512 k; output_buffers 1 128 k ;}

When aio is enabled, directio is automatically enabled. files smaller than the size defined by directio are sent using sendfile. Files larger than or equal to the size defined by directio are sent using the aio thread pool, that is to say, aio and directio are suitable for large file downloads. because large files are not suitable for accessing the operating system's buffers/cache, this will waste memory, and Linux AIO (asynchronous disk IO) also requires the directio format.

Sendfile_max_chunk can reduce the maximum time it takes to block sendfile () calls, because Nginx does not try to send the entire file at one time, but each time it sends block data with a size of kb.

Note that Nginx has introduced thread pool support for AIO from 1.7.11, and can use multiple threads to read and send files, so as to prevent the worker process from being blocked. to enable multi-threaded support, you must explicitly add the -- with-threads option to configure.

What is directio...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.