HAProxy 调度算法

2019-03-20  本文已影响0人  Alexander_Zz

静态算法


动态调度算法


source 算法

listen web_port_http_nodes
  bind 192.168.7.101:80
  node http
  balance source
  hash-type consistent
  log global
  option forwardfor
  server 192.168.7.101 192.168.7.101:8080 check inter 3000 fall 3 rise 5
  server 192.168.7.102 192.168.7.102:8080 check inter 3000 fall 3 rise 5

uri 算法

listen web_port_http_nodes
  bind 192.168.7.101:80
  mode http   # 不支持 tcp,会切换到 tcp 的 roundrobin 负载模式
  balance uri
  hash-type consistent
  log global
  option forwardfor
  server 192.168.7.101 192.168.7.101:8080 check inter 3000 fall 3000 rise 5
  server 192.168.7.102 192.168.7.102:8080 check inter 3000 fall 3 rise 5

url_param 算法

listen web_port_http_nodes
  bind 192.168.7.101:80
  mode http   # 不支持 tcp,会切换到 tcp 的 roundrobin 负载模式
  balance url_param NAME   # 基于参数 NAME 做 hash
  hash-type consistent
  log global
  option forwardfor
  server 192.168.7.101 192.168.7.101:8080 check inter 3000 fall 3 rise 5
  server 192.168.7.102 192.168.7.102:8080 check inter 3000 fall 3 rise 5

hdr 算法

listen web_port_http_nodes
  bind 192.168.7.101:80
  mode http
  balance hdr(User-Agent)
  hash-type consistent
  log global
  option forwardfor
  server 192.168.7.101 192.168.7.101:8080 check inter 3000 fall 3 rise 5
  server 192.168.7.102 192.168.7.102:8080 check inter 3000 fall 3 rise 5

image.png

rdp-cookie 算法

listen RDP
  bind 192.168.7.101:3389
  balance rdp-cookie
  mode tcp
  server rdp0 192.168.10.20:3389 check inter 2000 fall 3 rise 5 weight 1
  server rdp1 192.168.10.30:3389 check inter 2000 fall 3 rise 5 weight 1
 ~]# iptables -t nat -A PREROUTING -d 192.168.7.101 -p tcp --dport 3389 -j DNAT --to-destination 192.168.10.20:3389
~]# iptables -t nat -A POSTROUTING -s 192.168.0.0/21 -j SNAT --to-source 192.168.7.101

算法总结

image.png
上一篇 下一篇

猜你喜欢

热点阅读