Theory-LVS Load Balancing Cluster

1. Overview of enterprise cluster applications

1.1 The meaning of cluster

  • Cluster, cluster, cluster
  • Consists of multiple hosts, but only externally appears as a whole

1.2 The problem

  • In the application of the Internet of Things, as the site has higher and higher requirements for hardware performance, response speed, service stability, and data reliability, a single server is unable to do so

1.3 Solution

  • Use expensive minicomputers and mainframes
  • Use ordinary servers to build service clusters

Two, enterprise cluster classification

2.1 According to the target difference of the cluster, the function can be divided into three types

  • Load balancing cluster
    ◆ Perform health check, manage scheduling
  • High-availability cluster
    ◆ Two load balancing servers to achieve high availability, even if one load balancing server is down, it is still available and reliable; the two servers may not be geographically located together, one can be in Beijing and the other In Nanjing
  • High-performance computing cluster
    ◆ A large service request comes in, a single processing of 30 minutes, is assigned to the following nodes, reducing time

2.2 Load Balance Cluster

  • Improve the responsiveness of the application system, handle more access requests as much as possible, reduce latency as the goal, and obtain high concurrency and high load (LB) overall performance
  • The load distribution of LB depends on the distribution algorithm of the master node (the distribution algorithm is the scheduling algorithm)

2.3 High Availability Cluster

  • The goal is to improve the reliability of the application system, reduce the interruption time as much as possible, and ensure the continuity of services to achieve the fault tolerance effect of high availability (HA)
    ◆ HA means high availability, and clusters can support high availability
  • The working mode of HA includes duplex and master-slave modes.
    ◆ Duplex means that both servers are in working state. The decentralized cluster mechanism belongs to the level level, and the received information can be processed; examples of decentralized mechanism: For example, redis
    ◆ The master-slave is a centralized cluster, one is the master, and the others are all slave servers for backup

2.4 High Performance Computer Cluster

  • With the goal of increasing the CPU computing speed of the application system, expanding hardware resources and analysis capabilities, obtaining high-performance computing (HPC) capabilities equivalent to large-scale, supercomputers
  • The high performance of the high-performance computing cluster relies on "distributed computing" and "parallel computing". The CPU, memory and other resources of multiple servers are integrated through dedicated hardware and software to achieve computing capabilities that only large and supercomputers have
    ◆ Integrate ordinary servers to obtain high-level computing power equivalent to supercomputers
    ◆ Computing power: CPU, GPU, motherboard chips, bandwidth, and optimization of the computer's operating speed are all within the consideration of computing power

Three, load balancing cluster architecture

3.1 The structure of load balancing

  • The first layer, load scheduler (Load Balancer or Director)
  • The second layer, the server pool (Server Pool)
  • The third layer, shared storage (Share Storage)

Insert picture description here

Fourth, analysis of load balancing cluster working mode

  • Load balancing cluster is currently the most commonly used cluster type in enterprises
  • The cluster load scheduling technology has three working modes:
    Address translation-NAT mode
    ◆ IP tunnel
    ◆ Direct routing-DR mode

4.1 NAT mode-address translation

  • Network Address Translation, referred to as NAT mode
  • Similar to the private network structure of a firewall, the load scheduler serves as the network management of all server nodes, that is, as the access entrance of the client, and also the access exit of each node in response to the client
  • The server node uses a private IP address and is located on the same physical network as the load scheduler, and the security is better than the other two methods

Insert picture description here

4.2 TUN mode-IP tunnel

  • IP Tunnel, TUN mode for short
  • Adopting an open network structure, the load scheduler only serves as the client's access portal, and each node directly responds to the client through its own Internet connection, instead of passing through the load scheduler
  • The server nodes are scattered at different locations in the Internet, have independent public IP addresses, and communicate with the load scheduler through a dedicated IP tunnel

Insert picture description here
Note:

  • Dedicated IP tunnel for encryption-VPN, tunnel encryption, data encryption
  • The scheduler is the only entry point

4.3 DR mode-direct routing

  • Direct Routing, referred to as DR mode
  • It adopts a semi-open network structure, which is similar to the structure of the TUN model, but the nodes are not scattered everywhere, but are located on the same physical network as the scheduler
  • The load scheduler is connected to each node server through the local network, without the need to establish a dedicated IP tunnel

Insert picture description here

Operating mode Features
NAT mode-address translation (Network Address Translation) Similar to a firewall-like private network structure, the load scheduler serves as the network management of all server nodes, that is, as the access entrance of the client, and the load scheduler is also the access exit of each node in response to the client. The server node uses a private IP address and is located in The same physical network is more secure than the other two methods
TUN mode-IP tunnel (IP Tunnel) With an open network structure, the load scheduler is only used as the client's access portal. Each node directly responds to the client through its own Internet connection, instead of passing through the load scheduler. The server nodes are scattered in different locations in the Internet. All nodes Both have independent public IP addresses, communicate with the load scheduler through a dedicated IP tunnel
DR mode-Direct Routing It adopts a semi-open network structure, which is similar to the structure of the TUN model, but the nodes are not scattered everywhere, but are located on the same physical network as the scheduler. The load scheduler is connected to each node server through the local network and does not need to be established Dedicated IP tunnel

Note:

  • LVS can only filter based on the four-layer tcp/udp protocol
  • nginx is 7 layers
  • Alibaba Cloud's SLB is based on the four-layer and seven-layer protocol for filtering

Five, about LVS virtual server

5.1 Linux Virtual Server

  • Load balancing solution for Linux kernel
  • Founded by Dr. Zhang Wensong in my country in May 1998
  • Official website: http://www.linuxvirtualserver.org/

Insert picture description here

5.2 LVS load scheduling algorithm

5.2.1 Round Robin

  • The received access requests are allocated to each node (real server) in the cluster in turn in order, and each server is treated equally, regardless of the actual number of connections and system load of the server

5.2.2 Weighted Round Robin

  • According to the processing capacity of the real server, the received access requests are allocated in turn. The scheduler can automatically query the load status of each node and dynamically adjust its weight
  • Ensure that servers with strong processing capabilities bear more traffic

Note:
Weighted polling: also called weight, the number of assigned visits

5.2.3 Least Connections

  • Assign according to the number of connections established by the real server, and prioritize the received access requests to the node with the least number of connections

5.2.4 Weighted Least Connections

  • In the case of large differences in server node performance, the weight can be automatically adjusted for the real server
  • Nodes with higher weights will bear a greater proportion of active connection load

Six: ipvsadm tool

6.1 LVS cluster creation and management

Insert picture description here

Guess you like

Origin blog.csdn.net/ZG_66/article/details/108710372