# Static Files

**URL:** <https://www.ruby-forum.com/t/static-files/212259>\
**Category:** NGINX\
**Created:** [September 27, 2011, 1:37pm UTC](https://www.ruby-forum.com/t/static-files/212259 "2011-09-27T13:37:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [September 27, 2011, 1:37pm UTC](https://www.ruby-forum.com/t/static-files/212259/1 "2011-09-27T13:37:26Z")

</div>

Hi

I am intend to use NGINX (LINUX) for serving static files with high  
concurrency and bandwidth.  
Some of the files is served from the disk and some from cache.  
I am trying to find the configuration for best performance.

I have some questions regarding NGINX configuration.

1. _output\_buffers 1 32k_

* * *

## This directive excepts 2 inputs can someone explain me the meaning of each input I can see that 32K is size of data (per fetch) when reading from a DIsk

what else it influences?  
When serving big files, best Disk utilization is in blocks of 1MB, is it  
OK  
to change this directive to 1024k?

1. _aio_

* * *

\*\*I read in Wiki the following  
_" This directive is usable as of Linux kernel 2.6.22. For Linux it is  
required to use directio, this automatically disables sendfile  
support."_  
when using AIO I must use _directio on_? (when testing I could see the  
file  
is served from the cache - which means it is not using O\_DIRECT)

1. \*sendfile  
\*----------------------------------------  
Is NGINX try to send a file using 1 sendfile call (count = file size)?  
If so when trying to send file residing only on the Disk, the server is  
blocked till end of transmition?  
In this model serving multiple files some on the disk and some cached is  
inefficient?

Will be happy to get any answer or opinion

Thanks  
Hagai

–

_Hagai A._  
Qwilt | Work: +972-72-2221644| Mobile: +972-54-4895656 |  
removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Hagai\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a9a28c/32.png) [@Hagai\_A](https://www.ruby-forum.com/u/Hagai_A)\
**Post date:** [September 28, 2011, 5:49am UTC](https://www.ruby-forum.com/t/static-files/212259/2 "2011-09-28T05:49:07Z")

</div>

1 output\_buffers

because static file used sendfile in nginx, and if you need modify file  
content, you need read file content to memory(example gzip filter), this  
memory size is output\_buffers.

first arg is buf number, second is buf size. if allocated memory greater  
than number\*size, nginx will send buf and then continue read;

2 aio

yes.

3 sendfile

first, sendfile have limit(2g - 1) in nginx, if file size is greater  
than  
limit, nginx will send partially everytime. second, because fd is  
NONBLOCK,  
so server is not block.

On Tue, Sep 27, 2011 at 7:36 PM, Hagai A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> * * *
> 
> \*" This directive is usable as of Linux kernel 2.6.22. For Linux it is  
> In this model serving multiple files some on the disk and some cached is

–  
douban:www.douban.com/people/mustang/

blog: www.pagefault.info

twitter: [www.twitter.com/minibobo](http://www.twitter.com/minibobo)

weibo: [Sina Visitor System](http://www.weibo.com/diaoliang)
