2016-12-02 141 views
0

我认为我在HAProxy conf中做了一些错误,因为在使用HAProxy和单个AWS实例完成的实际测试中,吞吐量下降到25%。以下是我的相关(非常简单)配置:HAProxy递减吞吐量

global 
    log   127.0.0.1 local2 
    chroot  /var/lib/haproxy 
    pidfile  /var/run/haproxy.pid 
    maxconn  20000 
    user  haproxy 
    group  haproxy 
    daemon 
    stats socket /var/lib/haproxy/stats 
defaults 
    mode     http 
    log      global 
    option     httplog 
    option     dontlognull 
    option http-server-close 
    option forwardfor  except 127.0.0.0/8 
    option     redispatch 
    retries     3 
    timeout http-request 10s 
    timeout queue   1m 

timeout connect   10s 
    timeout client   1m 
    timeout server   1m 
    timeout http-keep-alive 10s 
    timeout check   10s 
    maxconn     30000 
frontend localnodes 
    bind *:80 
    mode http 
    default_backend nodes 
backend nodes 
    mode http 
    balance roundrobin 
    hash-type consistent 
    option httpchk /health 
    server w1 xx.xx.xx.xx:80 check id 1 

我已启用日志记录。日志中的典型条目如下所示:

Dec 2 09:29:05 localhost haproxy[2782]: xx.xx.xx.xx:43908 
[02/Dec/2016:09:29:05.940] localnodes nodes/w1 38/0/0/1/41 200 130 - - 
---- 36/36/12/2/0 0/0 "GET /ep?key=123&message=XXQSYI HTTP/1.1" Dec 2 09:29:05 localhost haproxy[2782]: xx.xx.xx.xx:43920 
[02/Dec/2016:09:29:05.941] localnodes nodes/web01 39/0/0/0/40 200 160 
- - ---- 35/35/11/0/0 0/0 "GET /q1?key=123&val=123 HTTP/1.1" Dec 2 09:29:05 localhost haproxy[2782]: xx.xx.xx.xx:43933 
[02/Dec/2016:09:29:05.955] localnodes nodes/web01 24/0/0/1/26 200 134 
- - ---- 34/34/11/1/0 0/0 "GET /q1?key=123&val=123 HTTP/1.1" 

我的吞吐量是我的实例的直接流量的25%。这是糟糕的表现。我做错了什么吗?

编辑 下乡日志,一些日志清楚地显示,从HAProxy的到达服务器采取时间过高

Dec 2 10:56:59 localhost haproxy[25988]: xx.xx.xx.xx:39789 [02/Dec/2016:10:56:58.729] main app/app1 0/0/1000/1/1002 200 449 - - ---- 13/13/13/7/0 0/0 "GET/HTTP/1.1" 
Dec 2 10:56:59 localhost haproxy[25988]: xx.xx.xx.xx:39803 [02/Dec/2016:10:56:58.730] main app/app1 0/0/999/1/1000 200 377 - - ---- 12/12/12/7/0 0/0 "GET/HTTP/1.1" 
Dec 2 10:56:59 localhost haproxy[25988]: xx.xx.xx.xx:39804 [02/Dec/2016:10:56:58.730] main app/app1 0/0/999/1/1000 200 277 - - ---- 11/11/11/7/0 0/0 "GET/HTTP/1.1" 

回答

1

从你的日志,你的大部分时间花在连接到服务器。例如,您花费1000,999和999毫秒连接。这可能与您通过使用option http-server-close在每次事务后立即关闭到服务器的连接有关。所以,每次都必须重新建立TCP连接(如果这是请求之间的相同客户端)。总体而言,它看起来像你每个请求花费大约1秒,这听起来并不可怕。在使用HAProxy之前你看到了什么?