1 , LVS , NAT Introduction
lvs Yes linux Virtual Server in the real world Span style= "Color:rgb (51,51,51)" >b/s Structure of the network application in the load balancer to use, working in 7 Network layer in the Layer network model, which is usually said to be ip layer, because data processing is in linux
nat Yes network addresstranslation , the abbreviation for network address translation, with the help of nat , Private (reserved) address of " internal " When the network sends packets through the router, the private address is converted to a legitimate ip address, a local area network needs only a small number of ip address (even 1 internet
2 , a simple Lvs/nat Architecture
Here's my simple picture. Lvs/nat deployment architecture at the time of application:
Let's assume that Baidu is using this architectural model (in fact, what is the structure of Baidu I did not field research)
Then to simulate the user access to the situation of Baidu.
1. users in the browser input http://www.baidu.com, the user's computer through the network to inquire DNS, Www.baidu.com The IP address of the domain name .
2.DNS server through the user's address, in the server list to select a possible distance from the user's nearest LVS Virtual Services IP Address or an address that follows the polling policy.
can be used ping Www.baidu.com ip is returned. Span style= "Color:rgb (51,51,51)" > address, this ip address is our dns Return to our address. can also be used dig command, you can see www.baidu.com actually corresponds to 3 " Span style= "Color:rgb (51,51,51)" >ip address
3. the IP address obtained by the user's browser via DNS to access the LVS Server
4. Enter lvs/nat mode,theLVS is converted via NAT , To supply packets to APACHE or nginx -built reverse proxy servers;
5. The reverse proxy server eventually sends the request to the application server;
6. After the application server completes the user request, the data is fed back to the bottom-up order, and a request is finalized.
3 , some characteristics and characteristics
First, to turn on the server is allowed to forward packets:
Echo 1 >/proc/sys/net/ipv4/ip_forward
then, you need to check if the actual server has NAT the server is not added as the default gateway:
Route Add default GW 10.0.0.50
10.0.0.50 to be NAT The server address.
to use LVS NAT mode, perform these command line operations:
Ipvsadm–a–t 122.12.12.12:80–s RR
Ipvsadm–a–t 122.12.12.12:80–r 10.0.0.100:8000–m
Ipvsadm–a–t 122.12.12.12:80–r 10.0.0.101:8000–m
The first line adds a virtual load Balancer scheduler; - s RR with simple polling RR scheduling method;
The next two lines are used to add the actual server to the scheduler, where - M represents the adoption NAT Way to forward the packet.
We are here to use RR scheduling policy, is a static policy. In the actual server load capacity is quite good performance. If the service is different, you need to adjust the weight value of the actual application server .
4 , Lvs/nat disadvantages of the pattern
1, in order to overwrite the header address of the network packets entering and out of the cluster, the performance of the whole cluster will be affected when the load is heavier, and the load balancer can be a bottleneck . ;
2 , for larger sites that are available for download, commonly used 100M bandwidth is not enough, either to use greater bandwidth or to use hardware devices, but these methods cost a great deal; NAT mode bottlenecks, you can use DR (Direct routing) method to improve.
Lvs/nat Mode of Load balancing