我有一个在一个服务器上工作的网页。我们正在迁移到一个有3台服务器的新平台。
在迁移计划的第一步,我们需要将生成百分比(比如10% )传递给新集群,将90%传递给旧服务器。新的平台不需要有粘性会话(与memcached共享会话)。
有什么方法可以用haproxy来实现吗?
发布于 2013-07-04 18:19:59
这可以通过让haproxy连接到自身来实现,为您提供两层负载平衡。
第一个listen使用balance source选项和服务器权重在现有服务器和集群之间拆分通信量。第二层使用没有持久性的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发布于 2013-07-04 15:37:53
您可以在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.发布于 2013-07-04 15:38:52
在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 90https://serverfault.com/questions/520887
复制相似问题