nginx fastcgi_buffers设置
来源:互联网 发布:unity3d怎么导出fbx 编辑:程序博客网 时间:2024/06/06 20:06
打开nginx的warn级别error_log,看到如下信息:
2011/04/23 17:24:08 [warn] 9639#0: *44 an upstream response is buffered to a temporary file /tmp/fastcgi_temp/8/0/0000000008 while reading upstream, client: 118.118.118.118, server: sealinger.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.sealinger.com"
参考《分析 fastcgi_temp 错误以及 Nginx 的 Buffer 机制》一文:
先简单的说一下 Nginx 的 buffer 机制,对于来自 FastCGI Server 的 Response,Nginx 将其缓冲到内存中,然后依次发送到客户端浏览器。缓冲区的大小由 fastcgi_buffers 和 fastcgi_buffer_size 两个值控制。
比如如下配置:
fastcgi_buffers 8 4K;
fastcgi_buffer_size 4K;
fastcgi_buffers 控制 nginx 最多创建 8 个大小为 4K 的缓冲区,而 fastcgi_buffer_size 则是处理 Response 时第一个缓冲区的大小,不包含在前者中。所以总计能创建的最大内存缓冲区大小是 8*4K+4K = 36k。而这些缓冲区是根据实际的 Response 大小动态生成的,并不是一次性创建的。比如一个 8K 的页面,Nginx 会创建 2*4K 共 2 个 buffers。
当 Response 小于等于 36k 时,所有数据当然全部在内存中处理。如果 Response 大于 36k 呢?fastcgi_temp 的作用就在于此。多出来的数据会被临时写入到文件中,放在这个目录下面。同时你会在 error.log 中看到一条类似 warning。
显然,缓冲区设置的太小的话,Nginx 会频繁读写硬盘,对性能有很大的影响,但也不是越大越好,没意义,呵呵!
一步步调整参数,直到没有这个warn信息:
#syntax: fastcgi_buffers the_number is_size
#default: fastcgi_buffers 8 4k/8k
#context: http, server, location
#fastcgi_buffers 256 4k; # Sets the buffer size to 4k + 256 * 4k = 1028k
fastcgi_buffers 32 4k;
-----------------------------------------------------------
参考:http://wiki.nginx.org/HttpFcgiModule
fastcgi_buffer_size
syntax: fastcgi_buffer_size the_size
default: fastcgi_buffer_size 4k/8k
context: http, server, location
This directive sets the buffer size for reading the header of the backend FastCGI process.
By default, the buffer size is equal to the size of one buffer in
fastcgi_buffers
. This directive allows you to set it to an arbitrary value.
fastcgi_buffers
syntax: fastcgi_buffers the_number is_size
default: fastcgi_buffers 8 4k/8k
context: http, server, location
This directive sets the number and the size of the buffers into which the reply from the FastCGI process in the backend is read.
By default, the size of each buffer is equal to the OS page size. Depending on the platform and architecture this value is one of 4k, 8k or 16k.
On Linux you can get the page size issuing:
getconf PAGESIZE
it returns the page size in bytes.
Example:
fastcgi_buffers 256 4k; # Sets the buffer size to 4k + 256 * 4k = 1028k
This means that any reply by the FastCGI process in the backend greater than 1M goes to disk. Only replies below 1M are handled directly in memory.
转自:https://blog.gesha.net/archives/350/
2011/04/23 17:24:08 [warn] 9639#0: *44 an upstream response is buffered to a temporary file /tmp/fastcgi_temp/8/0/0000000008 while reading upstream, client: 118.118.118.118, server: sealinger.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.sealinger.com"
参考《分析 fastcgi_temp 错误以及 Nginx 的 Buffer 机制》一文:
先简单的说一下 Nginx 的 buffer 机制,对于来自 FastCGI Server 的 Response,Nginx 将其缓冲到内存中,然后依次发送到客户端浏览器。缓冲区的大小由 fastcgi_buffers 和 fastcgi_buffer_size 两个值控制。
比如如下配置:
fastcgi_buffers 8 4K;
fastcgi_buffer_size 4K;
fastcgi_buffers 控制 nginx 最多创建 8 个大小为 4K 的缓冲区,而 fastcgi_buffer_size 则是处理 Response 时第一个缓冲区的大小,不包含在前者中。所以总计能创建的最大内存缓冲区大小是 8*4K+4K = 36k。而这些缓冲区是根据实际的 Response 大小动态生成的,并不是一次性创建的。比如一个 8K 的页面,Nginx 会创建 2*4K 共 2 个 buffers。
当 Response 小于等于 36k 时,所有数据当然全部在内存中处理。如果 Response 大于 36k 呢?fastcgi_temp 的作用就在于此。多出来的数据会被临时写入到文件中,放在这个目录下面。同时你会在 error.log 中看到一条类似 warning。
显然,缓冲区设置的太小的话,Nginx 会频繁读写硬盘,对性能有很大的影响,但也不是越大越好,没意义,呵呵!
一步步调整参数,直到没有这个warn信息:
#syntax: fastcgi_buffers the_number is_size
#default: fastcgi_buffers 8 4k/8k
#context: http, server, location
#fastcgi_buffers 256 4k; # Sets the buffer size to 4k + 256 * 4k = 1028k
fastcgi_buffers 32 4k;
-----------------------------------------------------------
参考:http://wiki.nginx.org/HttpFcgiModule
fastcgi_buffer_size
syntax: fastcgi_buffer_size the_size
default: fastcgi_buffer_size 4k/8k
context: http, server, location
This directive sets the buffer size for reading the header of the backend FastCGI process.
By default, the buffer size is equal to the size of one buffer in
fastcgi_buffers
. This directive allows you to set it to an arbitrary value.
fastcgi_buffers
syntax: fastcgi_buffers the_number is_size
default: fastcgi_buffers 8 4k/8k
context: http, server, location
This directive sets the number and the size of the buffers into which the reply from the FastCGI process in the backend is read.
By default, the size of each buffer is equal to the OS page size. Depending on the platform and architecture this value is one of 4k, 8k or 16k.
On Linux you can get the page size issuing:
getconf PAGESIZE
it returns the page size in bytes.
Example:
fastcgi_buffers 256 4k; # Sets the buffer size to 4k + 256 * 4k = 1028k
This means that any reply by the FastCGI process in the backend greater than 1M goes to disk. Only replies below 1M are handled directly in memory.
转自:https://blog.gesha.net/archives/350/
1 0
- nginx fastcgi_buffers设置
- nginx.conf中fastcgi_buffers的解释
- nginx( 设置)
- nginx设置
- 【Nginx】nginx虚拟机设置
- Nginx:设置Nginx作为缓存
- <nginx.conf> nginx设置用户权限
- nginx常用设置
- nginx的rewrite设置
- 转nginx设置
- 设置Nginx 404页面
- nginx 的pathinfo设置
- Nginx 反向代理设置
- Nginx ssi 设置
- nginx多域名设置
- nginx多域名设置
- nginx多站设置
- Nginx 反向代理设置
- java练习--插入歌曲
- OpenCV Mat 转 ATL CImage
- 今天我的博客开通啦!!
- 哪三个汉字可以一笔写成?除了“一”和“乙”还有什么?
- 构造判断回数的函数并利用filter函数过滤掉非回数
- nginx fastcgi_buffers设置
- Linux下的定时计划任务——crontab
- Comparable与Comparator接口的区别
- mysql事务执行时间过长引起死锁
- LeetCode 392 Is Subsequence
- 【mysql】初识mysql
- 内核定时器和延时
- GSM模块_GSM设备和网络错误代码
- Android中的Audio播放:控制Audio输出通道切换