Directio sendfile aio

From an nginx book i read setting

###########
http {

sendfile on;
sendfile_max_chunk 512k;
aio threads=default;
directio 4m;
############

is good as it use (if i understand it correctly)

sendfile for files less than 4m and directio for files larger than 4m

But the above config is causing issues like static css files images etc
not
being served. I am not sure what exactly is the issue But commenting out

directio from the above fix it or commenting out sendfile fix it .

But adding them both creates a mess.

The question is is the above combination valid and if yes what might be
causing the issue .

You did not provide any configuration snippet for the thread pool you
are
using and only showing partial configuration bits.
I hope the unshown is configured properly…

B. R.

On Fri, Jan 22, 2016 at 10:08 AM, Anoop A. [email protected]

On Friday 22 January 2016 14:38:13 Anoop A. wrote:

From an nginx book i read setting

What’s the name of the book?

###########
http {

sendfile on;
sendfile_max_chunk 512k;
aio threads=default;
directio 4m;
############

is good as it use (if i understand it correctly)

In some specific use case scenarios these settings can be good.

The question is is the above combination valid and if yes what might be
causing the issue .

Could you provide the full configuration and a debug log
(see A debugging log)?

I’m unable to reproduce any issues on a simple configuration
example with the settings above.

wbr, Valentin V. Bartenev

On Friday 22 January 2016 16:30:38 Anoop A. wrote:

So the setting

sendfile on;
sendfile_max_chunk 512k;
aio threads=iopool; #thread_pool iopool is defined in the main context
directio 4m;

is good ?

[…]

I wouldn’t recommend these settings for everyone. Actually there
are no settings that work for everyone and that’s the reason why
these directives exist and tunable.

Direct IO is questionable if you aren’t serving gigabytes of movies.
You don’t need direct IO and aio if your working data set is less
than the amount of RAM.

“sendfile_max_chunk 512k” with “directio 4m” looks surplus.

Actually the default settings usually work well. So in general it’s
not a good idea to tune anything unless you’re experiencing problems
and fully understand what you’re going to change and why. Also you
need some metrics and/or benchmarks to test your settings, blind
tuning can make the result worse.

wbr, Valentin V. Bartenev

I think the weird issue I mentioned had something to do with
ngx_pagespeed
with a memcached backed and memcached was not running . It is working
fine
with memcached now running .

Somehow the sendfile and directio setting was affecting that. as I
mentioned the issue fixed with enabling either sendfile and directio on
with memcached not running (I think pagespeed falls back to a file based
cache if memcached is not running) .

Right now with

sendfile on;
sendfile_max_chunk 512k;
aio threads=iopool;
directio 4m;

and memcached running ;I dont see any issues .

if memcached is not running (used by pagespeed) and the above setting
produce weird errors that goes away if directio and sendfile is used in
a
mutually exclusive fashion.

#########
the book is NGINX High Performance
By Rahul S.

You can check the exact section in page #53 available in google books as
a
sample.
#########

So the setting

sendfile on;
sendfile_max_chunk 512k;
aio threads=iopool; #thread_pool iopool is defined in the main context
directio 4m;

is good ?

On Fri, Jan 22, 2016 at 3:35 PM, Valentin V. Bartenev [email protected]

On Friday 22 January 2016 17:25:42 Anoop A. wrote:

aio threads=default;
directio 100m;

[…]

Something like this can work better, since it reduces usage of Direct IO
only for reading really quite big files.

But a possible side effect of this setting will be slowdown of serving
such files.

wbr, Valentin V. Bartenev

My use case is mixed mass hosting environment where some vhost may be
serving large files and some may be serving small files and where adding
something like location /video with directio enabled is not practical as
I
being the webhost may not be knowing if the vhost user is serving a
video
etc .

In such cases …do you recommend using something like

sendfile on;
sendfile_max_chunk 512k;
aio threads=default;
directio 100m;

in the http context . The logic being

file served of size 100m or less use sendfile and anything larger than
100m
( in which case it may have a high chance of being a multimedia file) is
served via directio .

Part of these setting are derived from what I understood is good from