4

全部!

我有 3 个不同的 RESTful 服务器:w1、w2、w3

引用我的负载均衡器的客户端提供了名为“ip”(ipv4)的 url 参数。请求之间的 url 参数 ip 不同:

curl -XGET http://localhost:8080/api/v1/link?ip=x.x.x.x

我想使用 HASH 算法根据 ip 参数将 HAProxy 平衡到 w1、w2、w3。

HAProxy 配置如下:

global
    #daemon
    maxconn 3000

defaults
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http-in
    bind *:80
    default_backend workers

backend workers
    balance url_param ip
    hash-type consistent
    server w1 localhost:8080 weight 1 maxconn 1000 check
    server w2 localhost:8081 weight 1 maxconn 1000 check
    server w3 localhost:8082 weight 1 maxconn 1000 check

listen admin
    bind *:8088
    stats hide-version
    stats realm HAProxy\ statistics
    stats enable

我怎样才能做到这一点?

谢谢

4

1 回答 1

0

使用 HAProxy 1.6.4(及更低版本)选择源平衡算法。我认为这个算法应该做你的工作还是有选择的理由balance url_param

balance source
hash-type consistent

哈希类型是可选的,但可能很有用。这里有一些进一步的信息。

于 2016-04-19T07:38:08.610 回答