Cluster Load Balancing--LVS Load Balancing Theory

One: Principle of Load Balancing Cluster

1.1: Overview of enterprise cluster applications

  • The meaning of clusters

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

    • In Internet applications, as sites have higher and higher requirements for hardware performance, response speed, service stability, data reliability, etc., a single server is unable to do so
  • Solution

    • Use expensive minicomputers and mainframes
    • Use ordinary servers to build service clusters
  • The SLB in Alibaba Cloud is a typical load balancing scheduler, and ECS is a cloud host (virtual machine)

    SLB schedules ECS, multiple ECSs form a resource pool, forming the basis of cloud computing

1.2: Enterprise cluster classification

  • According to the target difference of the cluster, it can be divided into three types
    • Load balancing cluster
    • Highly available cluster
    • High-performance computing cluster
1.2.1: Load Balance Cluster
  • To improve the responsiveness of the application system, handle as many access requests as possible, and reduce latency as the goal, to obtain high concurrency and high load (LB) overall performance
  • The load distribution of LB depends on the distribution algorithm of the master node, which is the scheduling
1.2.2: High Availability Cluster
  • To improve the reliability of the application system and reduce the interruption time as much as possible, ensure the continuity of the service, and achieve the high availability (HA) fault tolerance effect
  • The working mode of HA includes duplex and master-slave modes
    • Duplex, coordinated work of two parallel states, replacing each other at any time
    • With a master-slave mode, one master, multiple slaves, called a centralized cluster
    • Decentralized mechanism: there is no real master, if there is, it is symbolic, all nodes work (Redis cluster is a typical decentralized mechanism)
1.2.3: 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.

1.3: 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
    • IP tunnel
    • Direct routing (DR)
1.3.1: NAT mode
  • Network Address Translation
    • Referred to as NAT mode, it is similar to the private network structure of the firewall. The load scheduler acts as the gateway 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

1.3.2: TUN mode
  • IP Tunnel
    • Referred to as TUN mode, it adopts an open network structure. The load scheduler is only used as the client's access entrance. Each node directly responds to the client through its own Internet connection without 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

1.3.3: DR mode
  • Direct Routing
    • Referred to as DR mode, it adopts a semi-open network structure, which is similar to the structure of TUN mode, 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

1.3.4: The difference between the three working modes
Difference in working mode NAT mode TUN mode DR mode
Real server (node ​​server)
Server number (number of nodes) Low 10-20 High 100 High 100
Real gateway Load scheduler Own router Free router
IP address Public network + private network public net Private network
advantage High security Wan environment encrypted data Highest performance
Disadvantage Low efficiency and high pressure Need tunnel support Can't span LAN

Two: cluster architecture and virtual server

2.1: Architecture of a load balancing cluster

  • Load balancing architecture
    • 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

  • Shared storage provides a lot of storage space, benefits: convenient and efficient

2.2: Overview of LVS Virtual Server

  • Linux Virtual Server
    • Load balancing solution for Linux kernel
    • Founded by Dr. Zhang Wensong in my country in May 1998
[root@localhost~]# modprobe ip_vs   '确认内核对LVS的支持'
[root@localhost~]# cat /proc/net/ip_vs
  • LVS load scheduling algorithm
    • 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
    • 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
    • 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
    • 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

2.3: LVS cluster creation and management

  • Use ipvsadm tool
    • Create a virtual server
    • Add, delete server nodes
    • View cluster and node status
    • Error load distribution strategy

2.4: NFS shared storage service

  • Network File System, network file system

    • Rely on RPC (remote procedure call)
    • Need to install nfs-utils, rpcbind software package
    • System service: nfs, rpcbind
    • Shared configuration file: /etc/exports
  • Use NFS to publish shared resources

    • Install nfs-util, rpcbind software packages
    • Set up a shared directory
    • Start the NFS service program
    • View the NFS shared directory published by the machine
  • Access NFS shared resources in the client

    • Install the rpcbind package and start the rpcbind service
    • Manually mount NFS shared directory
      NFS publish shared resources
    • Install nfs-util, rpcbind software packages
    • Set up a shared directory
    • Start the NFS service program
    • View the NFS shared directory published by the machine
  • Access NFS shared resources in the client

    • Install the rpcbind package and start the rpcbind service
    • Manually mount the NFS shared directory
    • fstab auto mount settings

Guess you like

Origin blog.csdn.net/m0_47219942/article/details/108333675