# ZFS+NGINX, directio or sendfile or aio?



## meteor8488 (Apr 28, 2015)

Hi all,

I read some articles about nginx optimization. Lots of articles are using below settings:


```
aio  sendfile;
  sendfile  on;
  tcp_nopush  on;
  directio  4m;
  directio_alignment  4096;
```

But according to this article (https://calomel.org/nginx.html), zfs does't support directio, and sendfile on zfs will cause redundant data caching.

Now I'm confused. on FreeBSD-10.1 with ZFS and nginx, which option should I use?

Option 1


```
aio  sendfile;
  sendfile  on;
  tcp_nopush  on;
  tcp_nodelay on;
  directio  4m;
  directio_alignment  4096;
```

Option 2


```
aio  sendfile;
  sendfile  on;
  tcp_nopush  on;
  tcp_nodelay on;
```

Option 3

```
aio  on;
  sendfile  off;
  tcp_nopush  on;
  tcp_nodelay on;
```


----------



## meteor8488 (May 5, 2015)

Anyone can help?


----------



## drhowarddrfine (May 5, 2015)

Only the third option sets directio and talks about ZFS.


----------



## meteor8488 (May 5, 2015)

Do you mean that for ZFS, I should disable sendfile?

Thanks


----------



## drhowarddrfine (May 5, 2015)

I'm saying that, out of all those options, only the third one is about ZFS. I only looked at it briefly this morning. I, too, use it as a reference for doing my set up but I don't use ZFS. The first two, iirc, aren't for ZFS set ups.

When I first set up my servers, I knew more about this but haven't touched them in a year. Just read what they have to say more closely. If he says turn it off then turn it off. You won't blow anything up.


----------



## junovitch@ (May 6, 2015)

For ZFS/nginx performance, I remember reading allanjude@'s Managing FreeBSD @ Scale presentation and I believe his experience (and hopefully configuration snippets) may be helpful in answering your question.  

If not, try them all the run benchmarks.  Hunches and guess only go so far.  Prove what works best and document your findings for the benefit of others.


----------

