【发布时间】:2016-03-23 17:13:06
【问题描述】:
全部!
我有 3 个不同的 RESTful 服务器:w1、w2、w3
引用我的负载均衡器的客户端提供了名为“ip”(ipv4) 的 url 参数。请求之间的url参数ip不同:
curl -XGET http://localhost:8080/api/v1/link?ip=x.x.x.x
我想用HAProxy根据ip参数使用HASH算法平衡到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
我怎样才能做到这一点?
谢谢
【问题讨论】:
-
嗨。我尝试了您指定的配置,它似乎与您所要求的描述相匹配。您能否提供一个示例说明您当前的配置不适用的内容?我的另一个问题是帖子顶部的命令是测试命令吗?如果是这样,您不应该尝试连接到端口 80 上的 localhost 以查看它是否负载平衡,而不是端口 8080,还是我误解了?
标签: hash load-balancing haproxy balance