Three major load balancers LVS-Nginx-HAProxy

LVS:

1. 抗负载能力强,性能高,能达到F5的60%,对内存和CPU资源消耗比较低
2. 工作在网络4层,通过VRRP协议(仅作代理之用),具体的流量是由linux内核来处理,因此没有流量的产生。
3. 稳定,可靠性高,自身有完美的热备方案(Keepalived+lvs)
4. 不支持正则处理,不能做动静分离。
5. 支持多种负载均衡算法:rr(轮询),wrr(带权轮询)、lc(最小连接)、wlc(带权最小连接)
6. 配置相对复杂,对网络依赖比较大,稳定性很高。
7. LVS工作模式有4种:
    (1) nat 地址转换
    (2) dr 直接路由
    (3) tun 隧道
    (4) full-nat 

Nginx:

1. 工作在网络7层,可以针对http应用做一些分流的策略,比如针对域名,目录结构
2. Nginx对网络的依赖较小,理论上能ping通就能进行负载功能
3. Nginx安装配置比较简单,测试起来很方便
4. 也可以承担较高的负载压力且稳定,nginx是为解决c10k问题而诞生的
5. 对后端服务器的健康检查,只支持通过端口来检测,不支持通过url来检测
6. Nginx对请求的异步处理可以帮助节点服务器减轻负载压力
7. Nginx仅能支持http、https和Email协议,这样就在适用范围较小。
8. 不支持Session的直接保持,但能通过ip_hash来解决。对Big request header的支持不是很好。
9. Nginx还能做Web服务器即Cache功能。

HAProxy:

1. 支持两种代理模式:TCP(四层)和HTTP(七层),支持虚拟主机;
2. 能够补充Nginx的一些缺点比如Session的保持,Cookie的引导等工作
3. 支持url检测后端的服务器出问题的检测会有很好的帮助。
4. 更多的负载均衡策略比如:动态加权轮循(Dynamic Round Robin),加权源地址哈希(Weighted Source Hash),加权URL哈希和加权参数哈希(Weighted Parameter Hash)已经实现
5. 单纯从效率上来讲HAProxy更会比Nginx有更出色的负载均衡速度。
6. HAProxy可以对Mysql进行负载均衡,对后端的DB节点进行检测和负载均衡。
7. 支持负载均衡算法:Round-robin(轮循)、Weight-round-robin(带权轮循)、source(原地址保持)、RI(请求URL)、rdp-cookie(根据cookie)
8. 不能做Web服务器即Cache。

Remarks: The so-called layer 4 is load balancing based on IP + ports; layer 7 is load balancing based on application layer information such as URLs. Layer 4 receives requests through virtual IP + ports and then distributes them to real servers; layer 7 uses virtual URLs or The host name receives the request and then assigns it to the real server.

Published 51 original articles · won praise 2 · Views 6375

Guess you like

Origin blog.csdn.net/wenwang3000/article/details/99634955