Load Balancing Cluster - Lvs

Introduction to Load Balancing Clusters

  • Mainstream open source software LVS, keepalived, haproxy, nginx, etc.
  • Among them, LVS belongs to 4 layers (network OSI 7-layer model), nginx belongs to 7 layers, and haproxy can be regarded as 4 layers or 7 layers.
  • The load balancing function of keepalived is actually lvs
  • The 4-layer load balancing of lvs can distribute communication on other ports other than 80, such as MySQL, while nginx only supports http, https, mail, and haproxy also supports MySQL.
  • In comparison, the 4-layer LVS is more stable and can withstand more requests, while the 7-layer nginx is more flexible and can achieve more personalized needs

Introduction to LVS

  • LVS was developed by Chinese Zhang Wensong
  • As popular as apache's httpd, routing and forwarding based on TCP/IP has high stability and efficiency
  • The latest version of LVS is based on Linux kernel 2.6 and has not been updated for many years
  • LVS has three common modes: NAT, DR, IP Tunnel
  • There is a core role in the LVS architecture called Load balance, which is used to distribute user requests, and there are many servers (Real Server, rs for short) that process user requests.

LVS NAT mode

  • This mode is implemented with the help of the nat table of iptables
  • After the user's request reaches the distributor, the requested data packet is forwarded to the back-end rs through the preset iptables rules.
  • rs needs to set the gateway to the intranet ip of the distributor
  • The data packets requested by the user and the data packets returned to the user all pass through the distributor, so the distributor becomes the bottleneck
  • In nat mode, only the distributor needs to have a public network ip, so it saves public network ip resources

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324866883&siteId=291194637