关于Nginx均衡磁盘IO极高的问题

10 篇文章 0 订阅
http://hi.baidu.com/chancey/blog/item/9b5d480ace7f2c1495ca6bc3.html

关于Nginx均衡磁盘IO的问题解决
2009-12-16 18:54
由于某WEB业务I/O比较高 于是考虑使用nginx来均衡I/O负载
数据在服务器之间使用 lsyncd进行实时同步(效果相当不错)

前端使用nginx proxy来做load balance 配置相当简单, 过程具体就不说了

部署完毕后,功能上一切正常,唯独proxy服务器的load average巨高,查看发现Proxy服务器的Write I/O 占总消耗的90%以上。

这里比较纳闷, 因为业务本身很少有写操作, iotop查看消耗全在nginx上,但怎么也想不通什么东西如此消耗I/O,于是打开nginx error log并设置等级为debug。

观察了一段时间,发现每次request都要先在proxy本地找一下缓存,没有的时候才去请求真实服务器,其实配置中我并没有设置proxy_stroe之类的参数,因为本身就是要负载I/O ,如果都Cache到proxy上 那就达不到真正的目的了,更何况Cache不太适合大量的不算小的文件。

看了一下 nginx wiki proxy章发现以下选项:

proxy_buffering

syntax: proxy_buffering on|off

default: proxy_buffering on

context: http, server, location

This directive activate response buffering of the proxied server.

If buffering is activated, then nginx assumes the answer of the proxied server as fast as possible, preserving it in the buffer, assigned by directive proxy_buffer_size and proxy_buffers.

If the response can not all be placed in memory, then parts of it will be written to disk.

If buffering is switched off, then the response is synchronously transferred to client immediately as it is received.

nginx do not attempt to count entire answer of the proxied server, maximum size of data, which nginx can accept from the server it is assigned by directive proxy_buffer_size.

For Comet applications based on long-polling it is important to set proxy_buffering to off, otherwise the asynchronous response is buffered and the Comet does not work.


总算发现问题所在了,设置off重启, 一切正常。

这么说来如果是单纯拿来做负载均衡而不做代理,此项应该是必关的,否则只有无谓的消耗。
但我在google上搜索 "proxy_buffering", 结果只有3000+条, 除了nginx中文wiki之外,其他再无中文介绍, 搜索 "nginx load balance" 确有3W+ , 大多数都讲proxy如何配置,千篇一律 。对这样的参数只字未提, 很是费解.....

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值