Haproxy负载均衡算法

本文介绍了Haproxy的负载均衡算法,包括roundrobin、static-rr、leastconn等,强调了leastconn在处理长连接时的优势,以及各种算法的适用场景。通过源IP地址、URI、URL参数或特定HTTP头部进行负载分配,提供粘性会话和高效资源利用。
摘要由CSDN通过智能技术生成

前言

前段时间在impala集群中用到Haproxy,秉着折腾的原则,略微整理一下Haproxy的负载均衡算法,大致看了一下,基本上包括了主流的负载均衡算法。都是英文就不翻译了。自己大致明白的算法就凑一句自己的理解,不理解和没听过的,就算了。

目前,我一直使用的是leastconn。

算法

roundrobin

轮询。

这就个就是轮询了,挨个分配机器。适合于服务器组中的所有服务器都有相同的软硬件配置并且平均服务请求相对均衡的情况。

Each server is used in turns, according to their weights.This is the smoothest and fairest algorithm when the server’sprocessing time remains equally distributed. This algorithm is dynamic, which means that server weights may be adjusted on the fly for slow starts for instance. It is limited by design to 4095 active servers per backend. Note that in some large farms, when a server becomes up after having been down for a very short time, it may sometimes take a few hundreds requests for it to be re-integrated into the farm and start receiving traffic. This is normal, though very rare. It is indicated here in case you would have the chance to observe it, so that you don’t worry.

static-rr

加权轮询。

haproxy起的这个名字也是好玩,不看注释谁能猜出来这个算法……

根据服务器的不同处理能力,给每个服务器分配不同的权值,使其能够接受相应权值数的服务请求。

Each server is used in turns, according to their weights. This algorithm is as similar to roundrobin except that it is static, which means that changing a server’s weight on the fly will have no effect. On the other hand, it has no design limitation on the number of servers, and when a server goes up, it is always immediately reintroduced into the farm, once the full map is recomputed. It also uses slightly less CPU to run (around -1%).

leastconn

最少连接数。

最少连接数均衡算法对内部中需负载的每一台服务器都有一个数据记录,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值