全部!
我有 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
我怎样才能做到这一点?
谢谢