ITeye博客

Haproxy 1.4-dev2: barrier of 100k HTTP req/s crossed

mryufeng · 2010-03-09 23:00 · 网络 · 编程语言 · C · C++ · nginx · C# · 软件测试 · Markdown

原文地址: http://haproxy.1wt.eu/10g.html

点滴优化造就了今天的性能, willy好样的,应该是目前软件做到的最好的数字 Introduction

  It was my first test since I moved house. I wanted to quickly plug the machines together to see if my work on version 1.4 went into the right direction, and most importantly was not causing performance drops. Verdict below confirms it. A new record of 108000 HTTP requests processed per second was broken, and a new record of 40000 forwarded HTTP requests per second was broken too.

  The first test only accepts a new connection, reads the request, parses it, checks an ACL, sends a redirect and closes. A session rate of 132000 connections per second could even be measured in pure TCP mode, but this is not very useful :

The second test forwards the request to a real server instead, and fetches a 64-byte object :

  These improvements are due to the ability to tell the system to merge some carefully chosen TCP packets at critical phases of the session. This results in lower number of packets per session, which in turn saves both bandwidth and CPU cycles. The smallest session is now down to 5-6 packets on each side, down from 9 initially.

评论(9)

  1. #9 楼 · fxltsbl · 2012-08-25 15:55

    A new record of 108000 HTTP requests processed per second was broken, and a new record of 40000 forwarded HTTP requests per second was broken too

    麻烦请教:HTTP requests processed 和 forwarded HTTP requests 什么区别? 为什么两个值差距这么大

  2. #8 楼 · yaoweibin · 2010-03-31 15:40

    mryufeng writes:

    [quote=yaoweibin]今天的发现: 1、Nginx的测试配置少了2台服务器,汗。。。但是对于测试结果应该影响不大。 2、今天我把请求的网页换成100K的大页面,两者测试结果相差不大,至少没有像昨天的测试结果那样明显。两者测试都几乎把1000M的网卡占满了。 [/quote] 你在同一台机器跑ab和haproxy?

    是的,一般ab只占一个CPU,还好的。

  3. #7 楼 · mryufeng · 2010-03-23 01:17

    yaoweibin writes:

    今天的发现: 1、Nginx的测试配置少了2台服务器,汗。。。但是对于测试结果应该影响不大。 2、今天我把请求的网页换成100K的大页面,两者测试结果相差不大,至少没有像昨天的测试结果那样明显。两者测试都几乎把1000M的网卡占满了。

    你在同一台机器跑ab和haproxy?

  4. #6 楼 · yaoweibin · 2010-03-19 15:21

    今天的发现: 1、Nginx的测试配置少了2台服务器,汗。。。但是对于测试结果应该影响不大。 2、今天我把请求的网页换成100K的大页面,两者测试结果相差不大,至少没有像昨天的测试结果那样明显。两者测试都几乎把1000M的网卡占满了。

  5. #5 楼 · mryufeng · 2010-03-18 21:39

    yaoweibin writes:

    跟HAProxy进行了一下比较,测试结果好像Nginx的性能好一点。由于我对HAProxy并不熟悉,以前甚至以为HAProxy没有多进程支持,十分孤陋寡闻。下面是我的Nginx和HAProxy的配置,请您看一下下面的HAProxy配置还有哪些地方可以优化一下,希望可以得到您的帮助。

    nginx的配置:

    worker_processes 4; tcp { tcp_nodelay off;

    upstream test{
        server 172.19.0.129;
        server 172.19.0.130;
        server 172.19.0.131;
        server 172.19.0.132;
        server 172.19.0.235;
        server 172.19.0.236;
        server 172.19.0.237;
        server 172.19.0.238;
        server 172.19.0.239;
        check interval=3000 rise=2 fall=5 timeout=500;
    }
    
    server {
        listen 1982;
        proxy_pass test;
    }
    

    }

    haproxy的配置:

    global log 127.0.0.1 daemon user yaoweibin nbproc 4

    defaults backlog 2048 balance roundrobin log global mode tcp retries 3 contimeout 6s clitimeout 600s srvtimeout 600s

    listen test 0.0.0.0:8080 server test-1 172.19.0.129:80 check inter 3s rise 2 fall 5 weight 10 server test-2 172.19.0.130:80 check inter 3s rise 2 fall 5 weight 10 server test-3 172.19.0.131:80 check inter 3s rise 2 fall 5 weight 10 server test-4 172.19.0.132:80 check inter 3s rise 2 fall 5 weight 10 server test-5 172.19.0.133:80 check inter 3s rise 2 fall 5 weight 10 server test-6 172.19.0.134:80 check inter 3s rise 2 fall 5 weight 10 server test-7 172.19.0.135:80 check inter 3s rise 2 fall 5 weight 10 server test-8 172.19.0.136:80 check inter 3s rise 2 fall 5 weight 10 server test-9 172.19.0.137:80 check inter 3s rise 2 fall 5 weight 10 server test-10 172.19.0.138:80 check inter 3s rise 2 fall 5 weight 10 server test-11 172.19.0.139:80 check inter 3s rise 2 fall 5 weight 10

    我的测试机器是一台四核的linux机器,请求获取的是203个字节的网页,后端有11台web服务器。由于在同一台服务器上用ab,当测试并发数大的时候,ab本身的CPU资源消耗有一定的影响。下面是测试结果:

    keepalive的请求 ab -k -n 10000 -c 10 http://127.0.0.1:1982/ haproxy 2007 请求/每秒 nginx 8148

    sudo ab -k -n 100000 -c 100 http://127.0.0.1:1982/ haproxy 8848 nginx 21726

    sudo ab -k -n 100000 -c 200 http://127.0.0.1:1982/ haproxy 11323 nginx 21594

    sudo ab -k -n 100000 -c 500 http://127.0.0.1:1982/ haproxy 13761 nginx 21319

    sudo ab -k -n 100000 -c 1000 http://127.0.0.1:1982/ haproxy 15229 nginx 19587

    sudo ab -k -n 100000 -c 2000 http://127.0.0.1:1982/ haproxy 13722 nginx 18254

    非keepalive的请求 sudo ab -n 10000 -c 10 http://127.0.0.1:1982/ haproxy 1476 nginx 1752

    sudo ab -n 10000 -c 100 http://127.0.0.1:1982/ haproxy 2547 nginx 2231

    sudo ab -n 10000 -c 200 http://127.0.0.1:1982/ haproxy 2525 nginx 4991

    sudo ab -n 10000 -c 500 http://127.0.0.1:1982/ haproxy 2356 nginx 4814

    sudo ab -n 10000 -c 1000 http://127.0.0.1:1982/ haproxy 2412 nginx 5075

    sudo ab -n 10000 -c 2000 http://127.0.0.1:1982/ haproxy 2287 nginx 4721

    这个测试太蹊跷了 我有空也看下... 理论上haproxy要快好多...

  6. #4 楼 · yaoweibin · 2010-03-18 18:12

    跟HAProxy进行了一下比较,测试结果好像Nginx的性能好一点。由于我对HAProxy并不熟悉,以前甚至以为HAProxy没有多进程支持,十分孤陋寡闻。下面是我的Nginx和HAProxy的配置,请您看一下下面的HAProxy配置还有哪些地方可以优化一下,希望可以得到您的帮助。

    nginx的配置:

    worker_processes 4; tcp { tcp_nodelay off;

    upstream test{
        server 172.19.0.129;
        server 172.19.0.130;
        server 172.19.0.131;
        server 172.19.0.132;
        server 172.19.0.235;
        server 172.19.0.236;
        server 172.19.0.237;
        server 172.19.0.238;
        server 172.19.0.239;
        check interval=3000 rise=2 fall=5 timeout=500;
    }
    
    server {
        listen 1982;
        proxy_pass test;
    }
    

    }

    haproxy的配置:

    global log 127.0.0.1 daemon user yaoweibin nbproc 4

    defaults backlog 2048 balance roundrobin log global mode tcp retries 3 contimeout 6s clitimeout 600s srvtimeout 600s

    listen test 0.0.0.0:8080 server test-1 172.19.0.129:80 check inter 3s rise 2 fall 5 weight 10 server test-2 172.19.0.130:80 check inter 3s rise 2 fall 5 weight 10 server test-3 172.19.0.131:80 check inter 3s rise 2 fall 5 weight 10 server test-4 172.19.0.132:80 check inter 3s rise 2 fall 5 weight 10 server test-5 172.19.0.133:80 check inter 3s rise 2 fall 5 weight 10 server test-6 172.19.0.134:80 check inter 3s rise 2 fall 5 weight 10 server test-7 172.19.0.135:80 check inter 3s rise 2 fall 5 weight 10 server test-8 172.19.0.136:80 check inter 3s rise 2 fall 5 weight 10 server test-9 172.19.0.137:80 check inter 3s rise 2 fall 5 weight 10 server test-10 172.19.0.138:80 check inter 3s rise 2 fall 5 weight 10 server test-11 172.19.0.139:80 check inter 3s rise 2 fall 5 weight 10

    我的测试机器是一台四核的linux机器,请求获取的是203个字节的网页,后端有11台web服务器。由于在同一台服务器上用ab,当测试并发数大的时候,ab本身的CPU资源消耗有一定的影响。下面是测试结果:

    keepalive的请求 ab -k -n 10000 -c 10 http://127.0.0.1:1982/ haproxy 2007 请求/每秒 nginx 8148

    sudo ab -k -n 100000 -c 100 http://127.0.0.1:1982/ haproxy 8848 nginx 21726

    sudo ab -k -n 100000 -c 200 http://127.0.0.1:1982/ haproxy 11323 nginx 21594

    sudo ab -k -n 100000 -c 500 http://127.0.0.1:1982/ haproxy 13761 nginx 21319

    sudo ab -k -n 100000 -c 1000 http://127.0.0.1:1982/ haproxy 15229 nginx 19587

    sudo ab -k -n 100000 -c 2000 http://127.0.0.1:1982/ haproxy 13722 nginx 18254

    非keepalive的请求 sudo ab -n 10000 -c 10 http://127.0.0.1:1982/ haproxy 1476 nginx 1752

    sudo ab -n 10000 -c 100 http://127.0.0.1:1982/ haproxy 2547 nginx 2231

    sudo ab -n 10000 -c 200 http://127.0.0.1:1982/ haproxy 2525 nginx 4991

    sudo ab -n 10000 -c 500 http://127.0.0.1:1982/ haproxy 2356 nginx 4814

    sudo ab -n 10000 -c 1000 http://127.0.0.1:1982/ haproxy 2412 nginx 5075

    sudo ab -n 10000 -c 2000 http://127.0.0.1:1982/ haproxy 2287 nginx 4721

  7. #3 楼 · mryufeng · 2010-03-12 14:21

    haproxy通过多进程的方式也是可以利用多smp的, 而且效率要比nginx高好多

  8. #2 楼 · yaoweibin · 2010-03-12 14:02

    最近我尝试在Nginx上实现简单的TCP proxy,测试代理到Nginx的请求,测试结果有原来Nginx 2/3到3/4的性能,还没有跟HAProxy进行比较过。我写的模块:http://github.com/yaoweibin/nginx_tcp_proxy_module。

    我觉得Nginx在SMP系统里面还是有优势的,等我的模块开发成熟了,我再来进行详细比较。

  9. #1 楼 · litaocheng · 2010-03-11 12:08

    :) 项目之道啊...

评论功能维护中,当前仅展示历史评论。