【MySQL】HAProxy1.6负载均衡分配策略新增first

来源:互联网 发布:淘宝客新手 编辑:程序博客网 时间:2024/05/24 06:29

对于mysql主主代理来说,绝对是一个福音。

经过测试,haproxy能够做到像参数功能描述的那样:

The first server with available connection slots receives the connection.

可用连接槽的第一个服务器接收连接。

并且在第一个服务器恢复之后,能够主动切回来。


for /l %i in (1,1,500) do @(mysql -h192.168.1.221 -P20001 -A -N -e "select concat(%i,'-',version(),'-',sysdate())")


first       The first server with available connection slots receives the                  connection. The servers are chosen from the lowest numeric                  identifier to the highest (see server parameter "id"), which                  defaults to the server's position in the farm. Once a server                  reaches its maxconn value, the next server is used. It does                  not make sense to use this algorithm without setting maxconn.                  The purpose of this algorithm is to always use the smallest                  number of servers so that extra servers can be powered off                  during non-intensive hours. This algorithm ignores the server                  weight, and brings more benefit to long session such as RDP                  or IMAP than HTTP, though it can be useful there too. In                  order to use this algorithm efficiently, it is recommended                  that a cloud controller regularly checks server usage to turn                  them off when unused, and regularly checks backend queue to                  turn new servers on when the queue inflates. Alternatively,                  using "http-check send-state" may inform servers on the load.

0 0
原创粉丝点击