• 推荐使用最新版火狐浏览器或Chrome浏览器访问本网站
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

upstream response is buffered to a temporary file -Nginx

服务器 紫鹰 4年前 (2020-06-05) 1715次浏览 0个评论 扫描二维码

Nginx 日志中“an upstream response is buffered to a temporary file …”问题解决

an upstream response is buffered to a temporary file

错误日志:warn:an upstream response is buffered to a temporary file

解决办法:

在nginx配置文件,php模块中添加:

fastcgi_buffers 64 256k;  
fastcgi_buffer_size 1m;

FastCGI Server 的 Response,Nginx 将其缓冲到内存中,然后依次发送到客户端浏览器。缓冲区的大小由 fastcgi_buffers 和 fastcgi_buffer_size 两个值控制;

fastcgi_buffers 控制 nginx 最多创建 64 个大小为 256K 的缓冲区;

fastcgi_buffer_size 则是处理 Response 时第一个缓冲区的大小,不包含在fastcgi_buffers中;

所以总计能创建的最大内存缓冲区大小是 64*256K+1M = 17M;

当 Response 小于等于 17M 时,所有数据当然全部在内存中处理。

如果 Response 大于 17M 呢?fastcgi_temp 的作用就在于此。多出来的数据会被临时写入到文件中,放在这个目录下面。同时你会在 error.log 中看到一条类似 warning:

an upstream response is buffered to a temporary file

显然,缓冲区设置的太小的话,Nginx 会频繁读写硬盘,对性能有很大的影响;

 

 

日志: a client request body is buffered to a temporary file

解决办法:

client_max_body_size 2050m;     
client_body_buffer_size 1024k;

版权所有丨如未注明 , 均为原创丨
转载请注明原文链接:upstream response is buffered to a temporary file -Nginx
喜欢 (1)
[谢谢打赏!]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址