Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Principle and characteristics of lvs

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

There are three common mode modes of lvs.

How does the first lvs/nat work? For example, Xiaoming is the client, the pony is the dispatcher, or lvs, and the stores are Readserver. Now Xiaoming wants a cake, but the nature of Xiaoming is notoriously gluttonous and lazy in the neighborhood. Xiaoming's family is rich and powerful, so the pony will be a cow and horse for Xiaoming. The most important point is that Xiaoming is very domineering. Every time he buys things, he doesn't give money, and he always asks the pony to give his signature letter to those shops, so every time he wants something. Will ask the pony (probably his servant or a friend who can stand his temper very much) to help him buy things. This is the end of the good story. After knowing the above story, it is much easier to understand the principle of lvs/nat mode. Now Xiao Ming asks the pony to buy a cake (this sentence is equivalent to a request from the client to lvs), and then whether the pony has the money. So you have to show the signed letter from the pony to the store that sells the cake before you can ask the store owner to give the cake to the pony. Only then can the pony give the cake to Xiao Ming. (this means changing the ip destination address in the data packet sent by the client to lvs to the ip of the realserver that provides the data to the client. Note that this action is also done in the lvs guy. Then lvs can send the data to realserver according to his scheduling algorithm. After realserver has processed the client's request, the data is sent to lvs. Lvs changes the original ip address of the data packet sent by the original client to its own ip address, and then changes the destination address (that is, the ip that was previously sent to realserver) to the ip address of the client. You should not have this doubt. Why not use the destination address encapsulated by lvs as the original ip address of lvs? I'll tell you that this is equivalent to a vector, and there must be a beginning before there is an arrow behind it. If you think about it this way, you can see that the whole process is to achieve communication, and you have to think of them all as a whole. )

How does the second lvs/tun work? There is no story about this, but the name of the task above still needs to be used. What about Xiaoming after being taught by his father this time? I've been much better. Now let's start to tell the story of Xiaoming and the pony and the store. Xiao Ming asked the pony to buy him a BMW, so the pony was very smart. The pony was afraid of being robbed on the way out, so he packed the money in a very safe bag before going. When he arrived at the BMW car point, he gave the bag to the merchant's banknote counter. Because the pony couldn't drive and didn't have a driver's license, the merchant directly brought the pony and the BMW back to Xiao Ming. The client sends a packet to lvs, and then lvs repackages the packet sent by the client. After sending the data to realserver,realserver and receiving the data packet for processing, it directly returns the data to the client.

How does the third lvs/dr work? This story is a little more humorous ~ the pony and the shops are happy to serve Xiaoming, and the pony and the shops are a team. However? Xiao Ming seems to be suffering from a disease that doesn't speak clearly, so only his good friend, Ma, can understand what he is saying. First of all, it should be clear that both lvs and realserver provide the same ip. You can think that lvs and realserver must be in the same broadcast domain, or it can be understood that they are on the same switch. After the client sends a packet to lvs,lvs, it will call the realserver that can provide data for the client according to the scheduling algorithm and arp protocol to return the data to the client, because all realserver give the scheduling right of ip to lvs, although it is the same ip external service, but because Xiao Ming is ill, the stores can not understand what Xiao Ming is saying, so lvs conveys it on their behalf.

LVS: use cluster technology and Linux operating system to achieve a high-performance, high-availability server with good scalability (Scalability), reliability (Reliability) and manageability (Manageability). Thank Dr. Zhang Wensong for providing us with such powerful and practical open source software.

The characteristics of LVS are:

1. He works above four layers, so he is hardly affected by the traffic io, which makes him the strongest king in the load balancer.

2. Low configuration, stable work, and complete dual-computer hot backup solutions, such as LVS+Keepalived and LVS+Heartbeat, but LVS/DR+Keepalived is the most frequently used in the implementation of the project.

3. A wide range of applications can be used for load balancing of all applications.

Here are his shortcomings.

6, the software itself does not support regular processing, can not do dynamic and static separation, in fact, many websites have a strong demand in this area, this is the advantage of Nginx/HAProxy+Keepalived.

7. If the website application is relatively large, the implementation of LVS/DR+Keepalived is more complex, especially if there is a Windows Server application behind the machine, if the implementation and configuration and maintenance process is more complex, relatively speaking, Nginx/HAProxy+Keepalived is much simpler.

The characteristics of Nginx are:

1. Working above layer 7 of the network, you can make some diversion strategies for http applications, such as domain name and directory structure, whose regular rules are more powerful and flexible than HAProxy.

2. Nginx has very little dependence on the network. In theory, it can carry out the load function as soon as it can ping, which is its advantage.

3. Nginx is easy to install and configure, and easy to test.

4. The load pressure is OK and stable, and can generally support more than tens of thousands of concurrent times.

5. Nginx can detect internal faults in the server through the port, such as the status code and timeout returned by the web page processed by the server, and will resubmit the request that returns an error to another node, but the disadvantage is that it does not support url detection to talk to session.

6. Nginx can only support http and Email.

7. Nginx is not only an excellent load balancer / reverse proxy software, but also a powerful Web server,

8. Nginx is becoming more and more mature as a Web reverse acceleration cache, and many friends have been put into production in the production environment, and the response is good, faster than the traditional Squid server, interested friends can consider using it as a reverse proxy accelerator.

The characteristics of HAProxy are:

1. HAProxy supports virtual hosting. Some friends said before that this does not support virtual hosting. I hereby correct it here.

2. It can supplement some shortcomings of Nginx, such as the maintenance of Session, the boot of Cookie and so on.

3. Detection of problems with servers that support url detection at the backend will be very helpful.

4. It is only a load balancing software. In terms of efficiency, HAProxy has a better load balancing speed than Nginx, and it is also better than Nginx in concurrent processing.

5. HAProxy can load balance Mysql reads, detect and load balance the backend MySQL nodes, but the performance is not as good as LVS when the number of MySQL slaves in the backend exceeds 10, so I recommend LVS+Keepalived.

6. There are more and more HAProxy algorithms, including the following 8:

① roundrobin, which means simple polling. Not to mention this, this is basically what load balancers have.

② static-rr, indicating that according to the weight, it is recommended to pay attention to

③ leastconn, which means that those with least connections should be dealt with first. It is recommended to pay attention to

④ source, which indicates that according to the request source IP, which is similar to Nginx's IP_hash mechanism, we use it as a way to solve the session problem.

⑤ ri, which represents the URI based on the request

⑥ rl_param, which indicates that according to the requested URl parameter 'balance url_param' requires an URL parameter name

⑦ hdr (name), which means that each HTTP request is locked according to the HTTP request header

⑧ rdp-cookie (name), which means that each TCP request is locked and hashed according to cookie (name).

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report