2

我有 2 个后端的 haproxy 设置:be1 和 be2

我正在使用 ACL 根据路径进行路由。

当 be2 开始形成队列时,对 be1 的请求会受到负面影响——通常需要 100 毫秒的时间需要 2-3 秒(就像对 be2 的请求一样)。

有没有办法让 be2 排队而不影响 be1 的性能?

在高峰期,我的服务量约为 2000 req/s。

    global
    log 127.0.0.1   local0
    log 127.0.0.1   local1 notice
    #log loghost    local0 info
    maxconn 2000
    #chroot /usr/share/haproxy
    user haproxy
    group haproxy
    daemon
    #debug
    #quiet
    ulimit-n 65535
    stats socket /var/run/haproxy.sock
    nopoll

defaults
    log global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    maxconn 2000
    contimeout  5000
    clitimeout  50000
    srvtimeout  50000

frontend http_in *:80
    option httpclose
    option forwardfor
    acl vt path_beg /route/1
    use_backend be2 if vt
    default_backend be1

backend be1
    balance leastconn
    option httpchk HEAD /redirect/are_you_alive HTTP/1.0
    server 01-2C2P9HI x:80 check inter 3000 rise 2 fall 3 maxconn 500

backend be2
    balance leastconn
    option httpchk HEAD /redirect/are_you_alive HTTP/1.0
    server 01-3TPDP27 x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-3CR0FKC x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-3E9CVMP x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-211LQMA x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-3H974V3 x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-13UCFVO x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-0HPIGGT x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-2LFP88F x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-1TIQBDH x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-2GG2LBB x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-1H5231E x:80 check inter 3000 rise 2 fall 3 maxconn 250
    server 01-0KIOVID x:80 check inter 3000 rise 2 fall 3 maxconn 250

listen stats 0.0.0.0:7474       #Listen on all IP's on port 9000
    mode http
    balance
    timeout client 5000
    timeout connect 4000
    timeout server 30000
    #This is the virtual URL to access the stats page
    stats uri /haproxy_stats        
    #Authentication realm. This can be set to anything. Escape space characters with a backslash.
    stats realm HAProxy\ Statistics 
    #The user/pass you want to use. Change this password!
    stats auth ge:test123
    #This allows you to take down and bring up back end servers.
    #This will produce an error on older versions of HAProxy.
    stats admin if TRUE

不知道我昨天怎么没有注意到这一点,但是看到 maxconn 设置为 2000 ......所以这可能是我的问题之一?

4

1 回答 1

2

有两种不同的 maxconn 设置。一个用于前端,另一个用于后端。前端的设置限制了传入的连接,因此即使您的后端可用,它也不会收到请求,因为它在前端排队。一旦请求通过前端,就会发生后端排队。前端受“默认”部分中的 maxconn 设置的影响,因此我会将其增加到 4000,例如,因为后端应该能够处理它。

请注意 maxconn 不限制每秒请求数,而是限制同时连接数。您可能有一些 HTTP 保持活动请求处于活动状态,这可能会极大地限制可用吞吐量。

于 2012-10-11T15:32:35.240 回答