hash - 使用 url_param 值的 HAProxy 平衡器?

标签 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

我想根据ip参数使用HASH算法平衡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

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

关于hash - 使用 url_param 值的 HAProxy 平衡器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34331133/

相关文章:

algorithm - redis bloom 和 cuckoo 过滤器在性能方面哪个更好?

ruby - 如何在 Ruby 中简化这个?

azure - 如何使 Azure 逻辑应用在多个区域之间具有高可用性?

database - 是否可以在microsoft sql server前面使用mysql proxy进行查询处理?

OAuth 和粘性 session

ruby - 如何按值对哈希数组进行排序?

php - 将 Windows CryptoAPI 盐和哈希转换为 PHP

ssl - HAProxy 1.5-dev19 无法加载 SSL 证书

tomcat - 客户端证书从haproxy转发到tomcat

haproxy - haproxy ddos​​ 防护的工作原理