Server Load balancer solutions include hardware and software solutions. Mainstream hardware solutions:
F5 BIG-IP
Citrix netscalar
A10 A10
Array
Redware
LVS (Linux virtual server) is a layer-4 network switching or routing software solution. It implements switching or routing through kernel framework module ipvs and a set of rules configured on the framework. Ipvsadm is a tool for configuring routing rules. Ipvs kernel-based netfilter framework module operates on its input chain and routes packets that need to be forwarded to the Real Server. Therefore, ipvs functions conflict with the functions of Netfilter filters and Nat tables. It is recommended that you do not configure the filter and Nat rules of iptables on the host that has deployed ipvs rules. LVS has four models: Nat, Dr, Tun, and fullnat.
Features of the NAT model:
1. The RS should use a private address.
2. The RS gateway must point to the dip ctor dip.
3. The rip and dip of RS must be in the same network segment.
4. The request and response messages all pass through ctor. In high-load scenarios, Director may become a bottleneck in system performance.
5. Supports port ing.
6. RS can use any operating system that supports cluster services.
Features of the Dr model:
1. RS can use private addresses or public addresses.
2. The RS gateway must not point to dip
3. RS and director must be in the same physical network (vro cannot be separated)
4. The request message passes through ctor, but the response message must not pass through director.
5. Port ing is not supported.
6. RS can use most operating systems
Features of the Tun model:
1. Rip, dip, and VIP must both be public IP addresses.
2. The RS gateway will not point to dip
3. The request message passes through ctor, but the response message must not pass through director.
4. Port ing is not supported.
5. The RS operating system must support the IP tunneling technology.
10 scheduling policies supported by LVS
Static Policy
Rr: Round Robin
WRR: Weight Round Robin
SH: Source hashing
DH: Destination hashing
Dynamic policy
LC: Least connection overhead = active * 256 + inactive. Select the minimum load value for scheduling.
Wlc: weight least connection overhead = (Active * 256 + inactive)/weight
Sed: Shortest Route CT delay overhead = (Active + 1) * 256/weight
NQ: nerver queue
Lblc: locality-based least connection DH + Lc
Lblcr: replicated and locality-based least connection
Session persistence Mechanism
Session binding: always directs the connection of the same requestor to the same RS (the scheduling method is still selected for the first request). The error tolerance capability is not available and the load balancing effect is lossy.
Session replication: Synchronize sessions between Rs. Therefore, each Rs holds all sessions in the cluster, which is not applicable to large-scale cluster environments.
Session server: Use a separately deployed server to manage sessions in a unified manner.
Frequently Used ipvs command tool options and parameter cluster services
Ipvsadm-A | E-T | u | f service-Address [-s scheduler] [-P [timeout] [-M netmask]
Ipvsadm-D-T | u | f service-address
Ipvsadm-C
-A: Add a cluster service.
-T: TCP
-U: UDP
-F: Firewall mark, which is usually used to bind two or more services to a service for processing;
Service-address:
-T ip: Port
-U ip: Port
-F firewall_mark
-S scheduling method. The default value is wlc.
-P Timeout: persistent connection, persistent connection
-E: modifies the defined Cluster service.
-D-T | u | f service-Address: deletes the specified cluster service.
RS Problems
Ipvsadm-A | E-T | u | f service-address-r server-Address [-G | I | M] [-W weight] [-x upper] [-y lower]
Ipvsadm-D-T | u | f service-address-r server-address
-A: Add rs to the specified CS.
-T |-u |-F service-address: Specifies the cluster service to which the RS is added.
-R: Specifies the RS, which can contain {IP [: Port]}. Only the LVS type that supports port ing allows different ports in the cluster service.
LVS type:
-G: Gateway, Dr
-I: ipip, Tun
-M: masquerade, Nat
-E: Modify the specified Rs attribute.
-D-T | u | f service-address-r server-Address: deletes an RS from the specified cluster service.
Save rules: (use output redirection)
Ipvsadm-save
Ipvsadm-S
Load the specified rule: (use input redirection)
Ipvsadm-R
Ipvsadm-Restore
View ipvs rules
-L [Options]
-N: IP address displayed in digital format
-C: displays information about the number of connections.
-- Stats: displays statistics.
-- Rate: Rate
-- Exact: displays the exact value of the statistical data.
LVS persistent connection
PCC: All requests sent from the same client to the VIP are directed to the same Rs.
PPC: All requests sent from a client to a port of a VIP are directed to the same Rs.
Pfmc: Port binding, port affinity. Bind two or more ports to the same service based on the firewall tag.
Example:
# Iptables-T mangle-A prerouting-d vip-p tcp -- dport cs_port-J mark -- Set-mark num (Num value between 0 and 99)
# Ipvsadm-a-f num
Dr Model configuration instance of LVS
Assume that a Web Cluster is configured with three hosts. One ctor and two real servers. VIP: 192.168.100.185, dip: 192.168.100.105, rip of RS1: 192.168.100.107, rip of RS1: 192.168.100.108. The three hosts are connected to the same vswitch, and the Web Services on the two real servers are installed and configured. The following describes how to configure the LVS cluster.
RS1 Configuration:
# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore# echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce# echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce## ifconfig lo:0 192.168.100.185 netmask 255.255.255.255 broadcast 192.168.100.185 up# route add -host 192.168.100.185 dev lo:0#
Rs2 Configuration:
# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore# echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce# echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce## ifconfig lo:0 192.168.100.185 netmask 255.255.255.255 broadcast 192.168.100.185 up# route add -host 192.168.100.185 dev lo:0
Director Configuration:
Install ipvsadm
# Yum install ipvsadm
# ifconfig eth0:0 192.168.100.185 netmask 255.255.0.0 broadcast up# route add -host 192.168.100.185 dev eth0:0# # iptables -t filter -F# ipvsadm -A -t 192.168.100.185:80 -s rr# ipvsadm -a -t 192.168.100.185:80 -r 192.168.100.107 -g# ipvsadm -a -t 192.168.100.185:80 -r 192.168.100.108 -g
This article is from the blog of "bee Huai Yu Shan Ren", please be sure to keep this http://deshanrenjian.blog.51cto.com/9324633/1569077
LVS learning Summary of Server Load balancer