lvs enterprise load balancing

First, load balancing

Load balancing cluster is shorthand for load balance cluster, translated into Chinese is load balancing cluster. Commonly used open source load balancing software nginx, lvs, haproxy, commercial hardware load balancing device F5, Netscale.

Common load balancer:

  • (1) The working protocol layers can be divided into:
    four load balancing (in the kernel layer): performs scheduling according to the request packet destination address and port
    seven load balancing (the application layer): The content request message scheduling, such scheduling are "agent" manner, such as varnish
  • (2) The hardware is divided into:
    hardware load balancing:
    the F5 The BIG-IP; Citrix's NetScaler
    software load balancing:
    a.TCP layer: the LVS, HaProxy, the Nginx;
    . B based on the HTTP protocol: Haproxy, Nginx, ATS (Apache Server Traffic), Squid, Varnish;
    c MySQL-based protocols: mysql-proxy.
Two, LVS

LVS is referred to as the Linux Virtual Server, which is the Linux Virtual Server. LVS can achieve technical goals are: to achieve load balancing through LVS technology and high-performance Linux operating system to achieve a highly available Linux server clusters, it has good reliability, scalability and operability. Thus at low cost to achieve optimal performance. LVS is open source software projects a load-balanced cluster, LVS architecture can be logically divided into scheduling layer, Server clustering and shared storage layer.

The principle:

Here Insert Picture Description(1) When a user initiates a request to the load balancing scheduler (Director Server), the dispatcher sends the requests to the kernel space to

(2) PREROUTING chain first receives a user request, determines target IP determine the local IP, packets destined for the INPUT chain

(3) IPVS is working on the INPUT chain, when the user requests arrive INPUT, IPVS request and sends the user that they have defined a cluster service for comparison, if the user requests a cluster service is defined, then the time IPVS We will be forced to modify the data package destination IP address and port, and a new data packet destined POSTROUTING chain

(4) POSTROUTING found close link packet destination IP address happens to be their own back-end server, then the time will eventually send packets through routing to the back-end server

LVS composition

LVS program consists of two parts, including ipvs and ipvsadm.

-  ipvs(ip virtual server):一段代码工作在内核空间,叫ipvs,是真正生效实现调度的代码。
- ipvsadm:另外一段是工作在用户空间,叫ipvsadm,负责为ipvs内核框架编写规则,定义谁是集群服务,而谁是后端真实的服务器(Real Server)

LVS related terms

  • DS: Director Server. Load balancing refers to the front end node.
  • RS: Real Server. The back-end server real work.
  • VIP: user request directly to the outside, as the target IP address of the user request.
  • DIP: Director Server IP, IP addresses and is mainly used for internal communication with the host.
  • RIP: Real Server IP, IP address back-end server.
  • CIP: IP Address Client IP, access to client

lVS back-end server scheduling three modes:

1、LVS/NAT
2、LVS/DR
3、LVS/Tun

LVS eight scheduling algorithms

1. round-robin rr

This is the simplest algorithm, is successively in a cyclic manner according to the schedule request to a different server, the biggest feature of the algorithm is simple. Polling algorithm assumes the ability to handle all server requests are the same, the scheduler will all requests equally distributed to each real server, regardless of the back-end RS configuration and processing power, very evenly distribute it.

  1. Weighted Round Robin wrr

This algorithm than rr algorithm concept of a weight, the weight can be set to the RS, the higher the weight, the more the number of requesting the distribution, the weights in the range 0 - 100. Mainly on an optimization algorithm and complement rr, the LVS will consider the performance of each server, and to give added value to the right of each server, if the value of A 1 to the server, to the server B is 2, then scheduling request to the server B would be twice server a. The higher the weight of the server, the more processing the request.

  1. Minimum link lc

This algorithm will be determined according to the number of connections to the back-end of the RS request distributed to whom, such as RS1 RS2 number of connections less than the number of connections, then the request priority issue RS1

  1. Weighted Least Connections wlc

This algorithm is more heavy weight of a concept than lc.

  1. Locality-Based Scheduling Algorithm lblc least connection

This algorithm is a scheduling algorithm target IP address request packet, the algorithm to find the nearest target IP addresses of all the servers used in accordance with the destination IP address requests, if this server is still available, and the ability to process the request the scheduler will try to choose the same server, otherwise it will continue to choose other available servers

  1. Complex algorithm based on locality minimal connection lblcr

The record is not a record to give the connection between the target IP and a server, it maintains the mapping between a destination IP to a group of servers from a single point of server load is too high.

  1. Destination address hashing scheduling algorithm dh

The algorithm is the target server with the IP mapping relationship by a hash function based on the target IP address appears if the server is unavailable or the load is too high, and sent to the target IP requests sent to the server will be fixed.

  1. Source address hashing scheduling algorithm sh

Guess you like

Origin blog.csdn.net/Y950904/article/details/93477999