First, Brief introduction LVS is a shorthand for Linux Virtual server and is a highly scalable and highly available cluster solution on Linux servers. Developed by Dr. Zhangwensong, it is now integrated into the Linux kernel module and implements a load balancing schedule of four layers (transport layer) at the kernel level. Principle:ii. working mode of LVSThere are three different modes of operation depending on how the backend server returns data:Mode
, LVS will automatically distinguish, so the overall system is very stable.4, no flow, the above has been mentioned. LVS simply distributes the request, and the traffic does not go out of it itself, so it can be used to do some line diversion. Without traffic, the IO performance of the Equalizer will not be affected by large traffic.5, basically can support all applications, because LVS work in the 4 layer, so it can load balance almost all applications, including HTTP, database, chat room and s
(round robin), WRR (with weighted rotation), LC (minimum Connection), WLC (minimum weight connection)6, the configuration is complex, dependence on the network is relatively large, high stability.Features of Ngnix:1, work in the network on the 7 layer, can be targeted for HTTP applications to do some diversion strategy, such as for the domain name, directory structure;2, Nginx dependence on the network is relatively small, in theory can ping through
has a request, but 1 hours later, some idle, some or 1001 requests, but static scheduling still distributed according to the rules of the requestRR: PollingWRR: Weighted pollingSH:sessionsharing Implementation session affinity : Session bindingDH: Send the same IP request to the same serverDynamic scheduling: Consider the server state, such as the number of active links, the number of inactive links, they occupy resources is not the sameLC:lestconnection least linkActive*256+inactive who's the
fails, lvs will automatically identify the problem, so the system is very stable as a whole.4. No traffic, as mentioned above. Lvs only distributes requests, but the traffic does not go out of it. Therefore, it can be used to distribute some lines. Without traffic, I/O performance of the balancer is not affected by large traffic.5. Basically, it supports all applications. Because lvs works on Layer 4, it can perform operations on almost all applications.Server Load balancerIncluding http, datab
optimization and supplement, LVS will consider the performance of each server, and add a weight to each server, if the weight of server A is 1, Server B has a weight of 2, then the request dispatched to Server B will be twice times the server A. The higher the weighted value of the server, the more requests are processed.3: The Minimum connection scheduling algorithm (LC) will dispatch the request to the server with the smallest number of successive4: Weighted minimum connection algorithm (
cluster configuration instanceconfiguration instructions for the same first scienceVirtual Server:Configuration structure:Virtual_server IP port or virtual_server fwmark int{...Real_server {...}...}Common parameters:Delay_loop Lb_algo RR|WRR|LC|WLC|LBLC|SH|DH: Define the scheduling method;Lb_kind nat| dr| TUN: type of cluster;Persistence_timeout Protocol TCP: Service protocol, TCP only supported;Sorry_server Real_server {Weight Notify_up Notify_down
the Real-server. ipvs implements eight load scheduling algorithms. Four scheduling algorithms are described here:
RR is called scheduling:
Equal distribution of R, regardless of load.
WRR Weighted Round scheduling:
Set high/low weights and assign them to R.
Minimum LC connection scheduling:
Dynamically assigned to R with few established connections.
Wlc weighted least connection scheduling:
Dynamically set the weight of R. When allocating new con
eth0 virtual_router_id 51 # ID between nodes should be the same as priority 100 # Master advert_int 1 authentication {auth_type pass # authentication method between nodes auth_pass 1111 # consistency between nodes} virtual_ipaddress {192.168.81.229 }# virtual host configuration virtual_server 192.168.81.229 6379 {# Set VIP port delay_loop 6 # Check real_server status lb_algo RR # LVS scheduling algorithm here using Weighted Round Robin: rr | WRR | LC | wlc
: WRR, dynamic
Static-rr: WRR, static
Leastconn: wlc, dynamic used to establish persistent connections
Source: It is recommended for TCP-based debugging and does not support cookie insertion mode. It is determined by the hash-type parameter as either dynamic or static
Ipvs: Sh
Nginx: ip_hash
Uri: scheduling is based on the left half of the URI in the Request Message (the part before the query condition) or all of the Uris. It is often used in scenario
scheduling, does not support slow start, static, no limit on the number of backend servers
Leastconn: Wlc, dynamic
Source: Used for dynamic requests that require session persistence. We recommend that you use this method for TCP-based scheduling without Cookie insertion, the hash-type parameter determines the smell of dunamic or the static equivalent to the sh of ipvs, And the nginx ip_hash
Uri: Mainly for the cache service area. Scheduling is perfo
mentioned above. LVS only distributes requests, but the traffic does not go out of it. Therefore, it can be used to distribute some lines. Without traffic, I/O performance of the balancer is not affected by large traffic.5. Basically, it supports all applications. Because LVS works on Layer 4, it can perform Load Balancing for almost all applications, including HTTP, databases, chat rooms, and so on.In addition, LVS does not completely identify node faults. For example, in the
scheduling policies, such as the minimum connection (LC), weighted least connections (WLC), and the minimum expected time delay (SED)
Ipvsadm-a-t 111.11.11.11: 80-r 10.120.210: 8000-m
Ipvsadm-a-t 111.11.11.11: 80-r 10.120.211: 8000-m
Add two actual servers (no Internet ip addresses required).-r is followed by the Intranet ip address and port of the actual server.-m indicates that packets are forwarded in NAT mode.
Run ipvsadm-L-n to view the actual s
Check Interval in seconds # delay_loop 6 # Set the load scheduling algorithm. Common scheduling algorithms are: rr, wlc, and # lb_algo rr # Set the LVS mechanism for load balancing, such as lc, lblc, sh, and dh, available in NAT, TUN, and DR modes # lb_kind NAT # session persistence time, which is very useful for dynamic web pages and provides a good solution for seesion sharing in the cluster system; # Your requests are distributed to a service node
, databases, chat rooms, and so on.In addition, lvs does not completely identify node faults. For example, in the wlc allocation mode, if a node in the cluster is not configured with a VIP, the entire cluster will not be available, in this case, the wrr allocation method will discard a machine. This problem is still being tested. Therefore, you must be careful when using lvs.Ii. Comparison results of nginx and lvs1. nginx works on Layer 7 of the netwo
Round Robin Scheduling;
Minimal connection scheduling;
Weighted Least connection Scheduling;
Based on connections with the least locality;
Local least join with replication;
Target address hash scheduling;
Hash scheduling of source addresses;
Round-robin algorithm (RR): requests are scheduled to different servers in a sequential loop. The most specific method of this algorithm is simple implementation, the polling algorithm assumes that all servers have the same processing capability. The sched
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.