Hash 使用url_参数值的HAProxy平衡器?

Hash 使用url_参数值的HAProxy平衡器?,hash,load-balancing,haproxy,balance,Hash,Load Balancing,Haproxy,Balance,全部 我有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

全部

我有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
我怎样才能做到这一点

感谢使用HAProxy 1.6.4(及更低版本)选择源平衡算法。我认为这个算法应该适合您的工作,或者选择
balance url_param

balance source
hash-type consistent

哈希类型是可选的,但可能很有用。更多信息。

您好。我尝试了您指定的配置,它似乎与您要求的配置描述相匹配。您能否提供一个示例,说明当前配置中哪些不起作用?我的另一个问题是,位于post顶部的命令是test命令吗?如果是这样,您是否应该尝试连接到端口80上的本地主机,以查看它是否负载平衡,而不是端口8080,或者我是否误解了?