+ Through a load balancer disaster tolerance switched domain - Concept Principle (4) common load balancing

=========================================
achieve several SLB technology
Taken: https : //cloud.tencent.com/developer/article/1028941
==================================== =====
common load balancing two categories:

  • Job application layer in the OSI network model, referred to as the application layer load balancing, load balancing or seven. It includes the following: HTTP redirect load balancing, DNS DNS load balancing, reverse proxy load balancing
  • Working Layer 4 (transport layer) in the OSI network model layer 4 and hereinafter referred to as four load balancing. Include the following: IP link layer load balancing, load balancing the data link layer

1, HTTP redirect load balancing
that load balancing methods suitable only for WEB server.
When the user makes a request, the server load balancing based on the HTTP request, re-calculate the actual address of the WEB server corresponding to the user 302 via the browser redirect. Then the user's browser 302 in accordance with response information, issues a request for actual WEB server.

Advantages: HTTP redirection scheme is relatively simple.
Disadvantages:
1) relatively poor performance , you need 2 request to return the actual results;
2) there is only suitable for use HTTP server

2, DNS load balancing DNS
stores a plurality of host address in the DNS domain, each domain name resolution request, can return a different IP address according to a load balancing algorithm. Such multiple WEB servers constitute a cluster by the DNS server provides load balancing services.

优点:由DNS来完成负载均衡工作,服务本身不用维护负载均衡服务器的工作。
缺点:
1)由于负载均衡服务器不是自己维护,没法做精细控制。
2)DNS在客户端往往带有缓存,服务器的变更很难及时反映到客户端上。如果真实的后端服务器宕机,客户端的请求也有可能依然被调度到有问题的服务器上。

3、反向代理负载均衡
反向代理服务器位于实际的服务器之前,他能够缓存服务器响应,加速访问,同时也启到了负载均衡服务器的效果。
反向代理服务器解析客户端请求,根据负载均衡算法转发到不同的后台服务器上。用户和后台服务器之间不再有直接的链接。请求、响应都由反向代理服务器进行转发。

优点:
1)和负载均衡服务集成在一起,部署简单。
2)使用了反向代理服务器后,真正的后端服务器可以使用内网地址,节约公网IP资源,有效阻断恶意的访问
缺点:所有请求、响应都需要经过反向代理服务器,其本身可能会成为性能的瓶颈。

这类常见的软件有Nginx,HaProxy。著名的Nginx服务器就可以部署为反向代理服务器,实现WEB应用的负载均衡。

4、IP链路层负载均衡


用户请求包到达负载均衡服务器114.100.20.200后,负载均衡服务器在操作系统内核层获取网络数据包,根据负载均衡算法获取真实后台服务器地址192.168.1.1,然后将数据包的目标地址改为192.168.1.1, 转发给内部服务器。整个过程都在内核层进行处理。收到192.168.1.1的响应包之后,会更改响应包的SRC IP,转发给客户端用户。
优点:采用IP层负载均衡算法,全部处理过程都在内核层(Ring 0)进行。和七层负载均衡相比,具有更好的性能。
缺点:由于所有的响应包都要经过负载均衡服务器,负载均衡服务器的网卡带宽,很容易成为系统的瓶颈,如果能够让响应包不经过负载均衡服务器,就可以极大的提升整个负载均衡服务器的服务能力。我们下面介绍的数据链路层负载均衡,就具有这个能力。


5、数据链路层负载均衡
数据链路层负载均衡,顾名思义,就是工作在TCP/IP协议最底层的数据链路层,进行负载均衡。我们常用的以太网中,在这一层主要采用数据帧进行通信,每个网卡都具有唯一的MAC地址,数据帧用MAC地址来标识数据的来源与目的地。数据链路层负载均衡通过修改数据包的MAC地址,实现负载均衡。

这种数据传输方式又称为三角传输,负载均衡数据分发过程中不修改IP地址,只修改目的MAC地址,通过配置真实物理服务器集群所有机器虚拟IP和负载均衡服务器IP一致,从而达到不修改数据包的源地址和目的地址就可以进行数据分发的目的,由于实际处理请求的真实物理服务器IP和数据请求目的IP一致,不需要通过负载均衡服务器进行地址交换,可将响应数据包直接返回给用户,避免负载均衡服务器网卡带宽成为瓶颈。这种负载均衡方式又称之为直接路由方式(DR)。

如上图所示,用户请求到达负载均衡服务器114.100.20.200后,负载均衡服务器将数据包的目的MAC地址更改为00:1e:ec:bc:5e:03,并不修改数据包目的IP,由于服务器集群所有服务器的虚拟IP地址和负载均衡服务器IP地址一致,因此数据可以正常传输到达MAC地址为00:1e:ec:bc:5e:03的机器上,该服务器处理完之后,将响应数据包发送到网关服务器,网关服务器直接将数据包发送给用户,响应数据不需要通过负载均衡服务器,这样就避免了负载均衡服务器成为传输瓶颈的可能。

数据链路层负载均衡是目前使用最广泛的一种负载均衡方式。著名的负载均衡开源产品LVS(Linux Virtual Server),同时支持上面的IP负载均衡和数据链路层负载均衡。是学习负载均衡技术必须了解的产品。

优点:基于数据链路层的负载均衡有非常好的性能。由于LVS不是使用套接字的机制,而是直接经由内核进行操作,突破了套接字65535的限制,理论上可以达到百万级别的响应。
确定:对网络拓扑也有比较大的限制,负载均衡服务器和后台服务器必须处于同一网络环境中才可以。

Guess you like

Origin www.cnblogs.com/yickel/p/10961981.html