如何减少 HAProxy 中的故障转移间隔?

如何减少 HAProxy 中的故障转移间隔?

我已经设置了 HAProxy,它运行良好。我观察到,当其中一个节点发生故障时,HAProxy 会立即检测到,但将现有流量切换/重定向到其余工作节点需要15-16秒(我用不同的配置检查了 50 次,但这个切换时间保持在 15-16 秒)。

有人能帮助我减少故障转移间隔吗?

我尝试了“inter”、“fastinter”、“fall”、“rise”配置,但我不知道具体什么会起作用。这是我现有的配置文件

更新:我可以将这 15-20 秒的时间缩短到5-6秒,但不能少于这个。有可能实现实时故障转移吗?我还在这里更新了最新的 haproxy.config

global
        log 127.0.0.1 local0 debug
        maxconn   45000 # Total Max Connections.
        daemon
        nbproc      2 # Number of processing cores.
        stats timeout 1s
defaults
        log global
        retries 1
        option redispatch
        timeout server 100s
        timeout connect 100s
        timeout client 100s
        timeout queue 100s

frontend localnodes
    bind *:9875
    mode tcp
    default_backend nodes

backend nodes
        mode tcp
        balance roundrobin  # Load Balancing algorithm
        server adapter1 172.20.38.62:9875 weight 1 check fall 1 inter 20ms
        server adapter2 172.20.38.64:9875 weight 10 check fall 1 inter 20ms

listen  stats   172.20.38.63:1936
        mode            http
        log             global
        maxconn 10
        timeout queue   100s
        stats enable
        stats hide-version
        stats refresh 10s
        stats show-node
        stats auth admin:password
        stats uri  /haproxy?stats

HAProxy.log

2016-01-07T13:41:30+00:00 example.com haproxy[16319]: Server nodes/adapter2 is UP, reason: Layer4 check passed, check duration: 0ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
2016-01-07T13:41:30+00:00 example03.com haproxy[16320]: Server nodes/adapter2 is UP, reason: Layer4 check passed, check duration: 0ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.




2016-01-07T13:42:01+00:00 example03.com haproxy[16319]: Server nodes/adapter1 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 1 active and 0 backup servers left. 1 sessions active, 0 requeued, 0 remaining in queue.
2016-01-07T13:42:01+00:00 example03.com haproxy[16320]: Server nodes/adapter1 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.



2016-01-07T13:42:39+00:00 example03.com haproxy[16320]: Connect from 172.20.38.61:57867 to 172.20.38.63:9875 (localnodes/TCP)

相关内容