求助:nginx直接return 403或者200,404,444等状态码性能比nginx把请求代理到后端的qps低

574 views
Skip to first unread message

leeji...@gmail.com

unread,
Jul 23, 2016, 2:32:55 AM7/23/16
to openresty

环境:
linux centos7,nginx为1.9.15版本。压测并发4w,总共发送80w请求。openfile 调整为65535,backlog为2048。
测试两个case:
nginx直接返回403和nginx把请求代理到后端,发现403的qps大概1.6w左右,而proxy到后端的qps大概2.2w左右。并且,看linux系统日志和nginx error日志没有任何错误信息。
配置文件:
server {
    listen       8088;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        return 403;
        proxy_pass http://124.239.x.x:8010;
    }

}

求大神帮忙分析一下,多谢多谢!

Zexuan Luo

unread,
Jul 24, 2016, 12:44:11 PM7/24/16
to openresty
很好奇 后端是做什么处理的。
另外,使用了什么方法来压测呢?

在 2016年7月23日星期六 UTC+8下午2:32:55,leeji...@gmail.com写道:

李圣佳

unread,
Jul 25, 2016, 7:07:59 AM7/25/16
to open...@googlegroups.com
1,后端也是一个nginx,后端的response是一个html静态页面
2,使用ab来做的压测

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

YuanSheng Wang

unread,
Jul 26, 2016, 8:56:29 AM7/26/16
to open...@googlegroups.com
2016-07-23 14:32 GMT+08:00 <leeji...@gmail.com>:

环境:
linux centos7,nginx为1.9.15版本。压测并发4w,总共发送80w请求。openfile 调整为65535,backlog为2048。

压测方法也很重要,ab 要添加 -k 。几万的并发,更推荐 wrk 来完成压力测试,因为 ab 客户端最多占用单个 cpu 资源,自身容易成为瓶颈。
 
测试两个case:
nginx直接返回403和nginx把请求代理到后端,发现403的qps大概1.6w左右,而proxy到后端的qps大概2.2w左右。并且,看linux系统日志和nginx error日志没有任何错误信息。
配置文件:
server {
    listen       8088;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        return 403;
        proxy_pass http://124.239.x.x:8010;
    }

}


proxy_pass 反向代理到后端,是应该开启长连接的。是否开启长连接,对QPS 效率影响还是蛮大的。


upstream http_backend {
    server 127.0.0.1:8080;

    keepalive 16;
}

server {
    ...

    location /http/ {
        proxy_pass http://http_backend;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        ...
    }
}
 

求大神帮忙分析一下,多谢多谢!

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html



--

YuanSheng Wang
---------------------------------------
OpenResty lover ^_^
Reply all
Reply to author
Forward
0 new messages