nginx反向代理上下行带宽相差很大

321 views
Skip to first unread message

Yifan Gao

unread,
Feb 19, 2014, 7:49:31 AM2/19/14
to ustc...@googlegroups.com
今天监控突然报警,延迟过高,查看了一下(ssh卡到爆),发现nginx反向代理的一台Windows主机(IIS)占用了大部分下行流量(1MB/s~18MB/s),但此时nginx的上行带宽仅有200kB/s左右。临时关闭nginx后延迟复正常。

这令我非常不解:
1、代理服务器是千兆网卡,峰值带宽应该在100MB/s以上,十几兆的流量不应该拖慢服务器,延迟不会这么高(内网ping值>800ms)。(ps:正常状况下直接从服务器scp文件能达到50MB/s左右)
2、代理服务器下行带宽远大于上行带宽,说明有许多从backend接收的数据并没有发送出去,起先以为是缓冲区过大导致的,但将缓冲区改小后,故障依旧。

ps1:nginx配置:
user www-data;
worker_processes 8;
pid /var/run/nginx.pid;

events {
  worker_connections 768;
  # multi_accept on;
}

http {


  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  
  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  gzip on;
  gzip_disable "msie6";

 
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 128k;
  client_max_body_size 8m;
  client_body_buffer_size 32k;
  proxy_ignore_client_abort on;
  proxy_connect_timeout 5;
  proxy_read_timeout 60;
  proxy_send_timeout 5;
  proxy_buffer_size 32k;
  proxy_buffers  4 64k;
  proxy_busy_buffers_size 128k;

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
}
 
ps2:环境
backend(windows server 2012 R2 IIS 8.0)
proxy(ubuntu 12.04  nginx1.1.19)

ps3:
backend上活跃的文件都是1G左右的rar压缩文件

请各位帮忙分析一下,不甚感激.

Yifan Gao

Bojie Li

unread,
Feb 19, 2014, 8:48:16 AM2/19/14
to USTC_LUG
类似的问题我两周前提过,最后也没搞清楚原因。

我当时的后端是 Apache/2.2,你这里是 IIS。
你在 Windows 机器上有观察 CPU 使用率吗?


--
-- 来自USTC LUG
请使用gmail订阅,不要灌水。
更多信息more info:http://groups.google.com/group/ustc_lug?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "USTC_LUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ustc_lug+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yifan Gao

unread,
Feb 19, 2014, 10:02:09 AM2/19/14
to ustc...@googlegroups.com
目前故障已经消失(自然消失),windows服务器CPU占用率约35%,查阅故障时期的监控日志,半小时内的平均CPU约47%,属于正常水平

感觉像是用户触发了nginx的某个DoS漏洞。。。。当时引发故障的是某个广东铁通ip

Yifan Gao

unread,
Feb 19, 2014, 10:13:22 AM2/19/14
to ustc...@googlegroups.com
其实情况略有不用:我的后端正常(没有丝毫卡住的迹象,添加外网权限映射后可以正常连接),但反向代理服务器出现较高的网络负载

Bojie Li

unread,
Feb 19, 2014, 1:30:58 PM2/19/14
to USTC_LUG
后端服务器的出带宽和反向代理服务器的入带宽大致相等吗?如果不是就是其他问题了。

如果这个问题是在用户下载大文件的时候出现的,试试在反向代理服务器 nginx.conf 的 http 块里加上 proxy_buffering off; 看问题是否解决。

Yifan Gao

unread,
Feb 20, 2014, 7:51:34 AM2/20/14
to ustc...@googlegroups.com
后端和反向代理出入带宽大致相等。
目前故障自然消失,暂时没办法测试

Yifan Gao

unread,
Mar 18, 2014, 12:18:20 PM3/18/14
to ustc...@googlegroups.com
添加 proxy_buffering off; 后问题解决。


在 2014年2月20日 上午2:30,Bojie Li <boj...@gmail.com>写道:
Reply all
Reply to author
Forward
0 new messages