# Tweak fastcgi\_buffer

**URL:** <https://www.ruby-forum.com/t/tweak-fastcgi-buffer/242751>\
**Category:** NGINX\
**Created:** [July 22, 2015, 11:50pm UTC](https://www.ruby-forum.com/t/tweak-fastcgi-buffer/242751 "2015-07-22T23:50:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [July 22, 2015, 11:50pm UTC](https://www.ruby-forum.com/t/tweak-fastcgi-buffer/242751/1 "2015-07-22T23:50:37Z")

</div>

Hello,

I need to tweak fastcgi\_buffer to 1m on a website that has heavy  
requests  
to avoid buffer. If I use a distro with 4096 pagesize, is it better to  
do  
256x 4k or 4x 256k?

[root@web ~]# getconf PAGESIZE  
4096  
[root@web ~]#

fastcgi\_buffer\_size 4k;  
fastcgi\_buffers 256 4k;

OR

fastcgi\_buffer\_size 256k;  
fastcgi\_buffers 4 256k;

Thanks!

Karl

---

<div class="post-metadata">

**Author:** ![karl\_j](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/77aa72/32.png) [@karl\_j](https://www.ruby-forum.com/u/karl_j)\
**Post date:** [July 23, 2015, 9:21pm UTC](https://www.ruby-forum.com/t/tweak-fastcgi-buffer/242751/2 "2015-07-23T21:21:48Z")

</div>

Hello!

On Wed, Jul 22, 2015 at 05:50:12PM -0400, Karl J. wrote:

> fastcgi\_buffer\_size 4k;  
> fastcgi\_buffers 256 4k;
> 
> OR
> 
> fastcgi\_buffer\_size 256k;  
> fastcgi\_buffers 4 256k;

I would recommend the latter. Or, alternatively, something like

```
fastcgi_buffers 8 128k;

```

Too many small buffers will result in extra processing overhead,  
and it’s unlikely to be a good solution.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![karl\_j](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/77aa72/32.png) [@karl\_j](https://www.ruby-forum.com/u/karl_j)\
**Post date:** [July 29, 2015, 10:46pm UTC](https://www.ruby-forum.com/t/tweak-fastcgi-buffer/242751/3 "2015-07-29T22:46:13Z")

</div>

On Thu, Jul 23, 2015 at 3:21 PM, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > [root@web ~]# getconf PAGESIZE
> 
> I would recommend the latter. Or, alternatively, something like
> 
> ```
> fastcgi_buffers 8 128k;
> 
> ```
> 
> Too many small buffers will result in extra processing overhead,  
> and it’s unlikely to be a good solution.

Thanks for the recommendation Maxim. There’s no issue setting the buffer  
to  
128k when the pagesize is 4k?

Karl

---

<div class="post-metadata">

**Author:** ![karl\_j](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/77aa72/32.png) [@karl\_j](https://www.ruby-forum.com/u/karl_j)\
**Post date:** [July 29, 2015, 11:59pm UTC](https://www.ruby-forum.com/t/tweak-fastcgi-buffer/242751/4 "2015-07-29T23:59:14Z")

</div>

Hello!

On Wed, Jul 29, 2015 at 04:45:31PM -0400, Karl J. wrote:

> > > 256x 4k or 4x 256k?  
> > > fastcgi\_buffer\_size 256k;  
> > > Thanks for the recommendation Maxim. There’s no issue setting the buffer to  
> > > 128k when the pagesize is 4k?

No issues, though large buffers imply some memory waste when last  
buffer isn’t fully used. So usually you should consider some  
balance between number of buffers and their size.

–  
Maxim D.

> **[nginx](http://nginx.org/)**
