Author: Early Zenwen
Email:wenchu.cenwc@alibaba-inc.com
blog:http://blog.csdn.net/cenwenchu79
Date:2009-5-26
Directory
Demand turns to learning ... 2
"Soft" load balancing ... 2
LVS (Linux Virtual Server) ... 3
Virtual Server three mode introduction ... 3
Virtual server Three comparison of modes ... 5
Virtual Server three mode practice ... 6
Simple stress test in three different modes ... 9
Ha-proxy. 10
Ha-proxy Installation and use ... 10
Ha-proxy Stress test results ... 15
"Soft" load learning experience ... 15
Virtual Server three mode practice
Server resources:
10.2.225.128 as the load balancer,10.2.225.136 and 10.2.225.139 as the backend server.
Install the Apache2.2.14 on 10.2.225.136 and 10.2.225.139, and then open port 80 to start the Web service.
1. Install the LVS Configuration tool (only need to install on load balancer)
Most Linux operating systems currently support virtual Server, so there is no need to compile the kernel, just download and install the User Configuration tool ipvsadmin. First check your Linux OS kernel version, my version is 2.6.18. Downloaded the ipvsadm-1.24.tar.gz from http://www.linux-vs.org/software/ipvs.html#kernel-2.6. The installation steps are as follows:
TAR–XZVF ipvsadm-1.24.tar.gz
Ln–s/usr/src/kernels/2.6.18-128.el5-i686/usr/src/linux (this must be done because you need to use directory/usr/src/linux to get the necessary external dependencies when compiling and installing)
Cd ipvsadm-1.24
Make && make install
Enter Ipvsadm, if you see the following to prove the installation was successful:
IP Virtual Server version 1.2.1 (size=4096)
Prot Localaddress:port Scheduler Flags
-> remoteaddress:port Forward Weight activeconn inactconn
2. Dr Mode Test
A. Bind virtual IP to 10.2.225.128 this load Balancer network card.
Ifconfig eth0:0 10.2.225.211 netmask 255.255.255.0 broadcast 10.2.225.211 up
B. Establish a virtual IP on the load balancer.
Ipvsadm–a–t 10.2.225.211:80–s RR//221 IP is not in use by a physical machine, so as a virtual IP use, a indicates that a virtual ip,t representation is a TCP protocol, s represents a load algorithm, and a RR is a round Robin.
C. Establish a relationship between virtual IP and two entity servers on the load balancer.
Ipvsadm-a-T 10.2.225.211:80-r 10.2.225.136:80-g-W 1//Connect virtual IP and port to the entity machine, a indicates the relationship between the new virtual IP and the entity machine, R followed by the entity machine address and port, G means to use Dr Mode , W is the weight.
Ipvsadm-a-T 10.2.225.211:80-r 10.2.225.139:80-g-W 1
D. Establish the binding relationship between virtual IP and network card loopback on two other entity servers.
Ifconfig lo:0 10.2.225.211 netmask 255.255.255.255 broadcast 10.2.225.211 up
The following figure is configured to enter IPVSADM to see the virtual configuration information
Where route representation is the mode of Dr, and then Activeconn represents the number of connections, this is to access a published on two back-end server of the number of connections, access to the page is as follows two map: (mainly to see the return page in the server IP printing different)
The results of the access page are the same as the DR, and access to the virtual IP is polled to different back-end servers.
Simple stress test in three modes
The simple stress test employs Apache ab,500 concurrent users, and the total number of 10w requests.
|
Total time consuming (s) |
TPS (#/sec) |
NAT |
22.480 |
4448.34 |
Tunnel |
10.707 |
9339.80 |
DR |