Haproxy%stream量到集群

我有一个网页,在1服务器的作品。 我们正在进行迁移到有3台服务器的新平台。

在迁移计划的第一步,我们需要通过一个百分比,比如10%,到新的集群和90%,到旧的服务器。 新平台不需要粘滞会话(与memcached共享会话)。

有没有办法做到这一点与haproxy

这可以通过haproxy连接到自己来实现,给你两层负载平衡。

第一个listen使用balance source选项和服务器权重来拆分现有服务器和群集之间的stream量。 第二层使用balance roundrobin没有持久性来轮换群集成员之间的传入连接。

 Listen 10.0.1.1:80 Balance source Server oldserver 10.0.1.10 weight 90 Server newcluster 10.0.1.20 weight 10 Listen 10.0.1.20:80 Balance roundrobin Server cluster1 10.0.1.31 Server cluster2 10.0.1.32 Server cluster3 10.0.1.33 

您可以在haproxy中定义权重,根据您的需要分配负载。

从官方haproxy 1.4文档:

 weight <weight> The "weight" parameter is used to adjust the server's weight relative to other servers. All servers will receive a load proportional to their weight relative to the sum of all weights, so the higher the weight, the higher the load. The default weight is 1, and the maximal value is 256. A value of 0 means the server will not participate in load-balancing but will still accept persistent connections. If this parameter is used to distribute the load according to server's capacity, it is recommended to start with values which can both grow and shrink, for instance between 10 and 100 to leave enough room above and below for later adjustments. 

在haproxy服务器部分使用权重。 “权重1代表最低频率,最高256”

 server newserver1 192.168.1.1:80 weight 3 server newserver2 192.168.1.2:80 weight 3 server newserver3 192.168.1.3:80 weight 3 server oldserver1 192.168.2.1:80 weight 90