Web load Balancing (IPVSADM,DR mode)

Source: Internet
Author: User


Ipvsadm load Balancing on Ubuntu (DR Mode, 80 ports for example)

Description: 3 Servers, IP: 10.0.1.2 10.0.1.3 10.0.1.4 Virtual ip:10.0.1.10


Ipvsadm Server (10.0.1.2)

$ sudo apt-get install Ipvsadm

$ sudo ifconfig eth0:0 10.0.1.10 netmask 255.255.255.255 Broadcast 10.0.1.10

$ sudo ip a (see if the settings are in effect)

$ sudo route add-host 10.0.1.10 Dev eth0:0

$ sudo route-n (see if the settings are in effect)

$ sudo ipvsadm-a-T 10.0.1.10:80-s RR (note RR is polling mode)

$ sudo ipvsadm-a-T 10.0.1.10:80-r 10.0.1.3:80-g

$ sudo ipvsadm-a-T 10.0.1.10:80-r 10.0.1.4:80-g

$ sudo ipvsadm--save (save Ipvsadm settings)

$ sudo ipvsadm-l (view ipvsadm settings)

$ sudo ipvsadm-c (clear ipvsadm settings)

$ sudo ipvsadm-a (add real server, such as: $ sudo ipvsadm-a-T 10.0.1.10:80-r 10.0.1.3:80-g)

$ sudo ipvsadm-d (remove real server, such as: $ sudo ipvsadm-d-T 10.0.1.10:80-r 10.0.1.3:80)

To set up boot from:

$ sudo vi/etc/rc.local (above exit 0)

Press A or I to enter edit mode

Ipvsadm-a-T 10.0.1.10:80-s RR (note RR is polling mode)

Ipvsadm-a-T 10.0.1.10:80-r 10.0.1.3:80-g

Ipvsadm-a-T 10.0.1.10:80-r 10.0.1.4:80-g

Ipvsadm--save

Press the ESC key to exit edit mode

: Wq (Save and exit)



Ipvsadm Client (10.0.1.3)


$ sudo ifconfig lo:0 10.0.1.10 netmask 255.255.255.255 Broadcast 10.0.1.10

$ sudo ip a (see if the settings are in effect)

$ sudo route add-host 10.0.1.10 Dev lo:0

$ sudo route-n (see if the settings are in effect)

$ sudo echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore

$ sudo echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore

$ sudo echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce

$ sudo echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce

To set up boot from:

$ sudo vi/etc/rc.local (above exit 0)

Press A or I to enter edit mode

Ifconfig lo:0 10.0.1.10 netmask 255.255.255.255 Broadcast 10.0.1.10

Press the ESC key to exit edit mode

: Wq (Save and exit)


Ipvsadm Client (10.0.1.4)


$ sudo ifconfig lo:0 10.0.1.10 netmask 255.255.255.255 Broadcast 10.0.1.10

$ sudo ip a (see if the settings are in effect)

$ sudo route add-host 10.0.1.10 Dev lo:0

$ sudo route-n (see if the settings are in effect)

$ sudo echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore

$ sudo echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore

$ sudo echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce

$ sudo echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce

To set up boot from:

$ sudo vi/etc/rc.local (above exit 0)

Press A or I to enter edit mode

Ifconfig lo:0 10.0.1.10 netmask 255.255.255.255 Broadcast 10.0.1.10

Press the ESC key to exit edit mode

: Wq (Save and exit)


Verify:


2 pages on 2 hosts respectively 1.html content write the respective host IP

Http://10.0.1.10/1.html

The first time will show 10.0.1.3

The second time will show 10.0.1.4



Ipvsadm Scheduling algorithm:


One, round call scheduling (Round-robin scheduling) RR
The round call scheduling (Round Robin scheduling) algorithm is called in turn to dispatch the request to a different server, that is, each time the dispatch executes i = (i + 1) mod n, and select the first server. The advantage of the algorithm is its simplicity, which does not need to record the state of all current connections, so it is a stateless dispatch.

Second, weighted round call scheduling (Weighted round-robin scheduling) WRR
The weighted round call scheduling (Weighted round-robin scheduling) algorithm can solve the performance difference between servers, it uses the corresponding weights to represent the server's processing performance, the server's default weight is 1. Assuming server A has a weight of 1,b of 2, it means that Server B's processing performance is twice times the value of a. Weighted round call scheduling algorithm is based on the weight of the high and low and round-robin allocation request to each server. A server that has a high weight value receives a connection that has a higher weight than a server that has a lower weight value and handles more connections than a server with the same number of weights.

Three, minimum connection scheduling (least-connection scheduling) LC
The minimum connection dispatch (Least-connection scheduling) algorithm is a server that assigns new connection requests to the least current number of connections. Minimum connection scheduling is a dynamic scheduling algorithm that estimates the server's load by the number of connections currently active on the server. The scheduler needs to record the number of connections that each server has established, and when a request is dispatched to a server, its number of connections increases by 1, and its number of connections is reduced by one when the connection is aborted or timed out.

Four, weighted minimum connection scheduling (Weighted least-connection scheduling) WLC
The weighted minimum connection scheduling (Weighted least-connection scheduling) algorithm is a superset of the minimum connection schedule, which is the default algorithm for Ipvsadm. Each server uses corresponding weights to represent its processing performance. The default weight of the server is 1, and the system administrator can set the server's weights dynamically. Weighted minimum connection scheduling makes the server's established connections and their weights proportional as much as possible when scheduling a new connection.



This article from "Linux" blog, declined reprint!

Web load Balancing (IPVSADM,DR mode)

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.