In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following gives you a detailed introduction to the principles of the three working modes of LVS load balancing cluster, hoping to bring some help to you in practical application. Load balancing involves more things, there are not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
LVS load balancing Cluster (detailed explanation of the principles of the three working modes) I. preface
In Internet applications, with the increasing requirements of the site for hardware performance, response speed, service stability, data reliability and so on, a single server is inadequate. So we need some ways to solve this bottleneck.
The easiest way is to use expensive large and small mainframes, but this is obviously undesirable or unrealistic in most enterprises. Then we need to build a server cluster through multiple ordinary cloud servers.
II. Overview of related concepts 2.2.What is LVS?
LVS--Linux Virtual Server, that is, Linux virtual server (virtual host, shared host), virtual host will not be discussed here, I believe we all understand.
LVS is a virtual server cluster system, which implements a high-performance and high-availability server. Currently, LVS has been integrated into the Linux kernel module.
The composition of 2.2LVS
① from a physical level, the main components of LVS are:
The load scheduler (load balancer/ Director), which is the front-end machine outside the entire cluster, is responsible for sending the customer's request to a set of servers for execution, and the customer thinks the service comes from an IP address (we can call it a virtual IP address). Server pool (server pool/ Realserver) is a group of servers that actually execute customer requests. The services performed are generally WEB, MAIL, FTP, DNS, and so on. Shared storage (shared storage), which provides a shared storage area for the server pool, which makes it easy for the server pool to have the same content and provide the same services
As shown in the following figure:
Add: generally, in order to achieve high availability, more than two scheduling servers will be used as backups to improve security. (later experimental deployment of DR mode + keepalive will use two load scheduling servers)
② from the software level, LVS consists of two parts of programs, including ipvs and ipvsadm.
1.ipvs (ip virtual server): a piece of code that works in kernel space, called ipvs, is the code that actually works to implement scheduling.
2.ipvsadm: the other section works in user space, called ipvsadm, which is responsible for writing rules for the ipvs kernel framework, defining who is the cluster service and who is the real back-end server (Real Server), and then the kernel code implements the real scheduling algorithm and functions.
2.3 what is clustering?
A cluster, or cluster in English, consists of multiple hosts, but the external performance is only as a whole (the same service). The client is unable to detect how many servers there are and has no idea which real server they are accessing.
According to the target difference, the cluster can be divided into three categories: load balancing cluster, high availability cluster (HA), and high performance computing cluster. I will introduce them one by one below.
2.4 how to understand load balancing?
Load balancing-load balance, as its name implies, as far as the server is concerned, can be understood as the "pressure" on multiple servers is relatively balanced. Here, "pressure" refers to the various resource requests or services that the server needs to respond to, and is relatively balanced. After all, the performance of the server and many other aspects may not be consistent.
Give a simple example to illustrate the meaning of load balancing. If you need to fetch a bucket of water, you can choose to carry it with one hand, but you may be tired. If you hold two buckets with both hands to hold the same amount of water and distribute it evenly, it's easier.
In fact, load balancing is essentially the principle of distributing tasks to multiple servers relatively evenly, which can not only reduce the pressure on one server, but also improve the speed of response and processing.
2.5 Type of cluster 2.5.1 load balancing cluster
Load balancing + clustering can improve the response ability of the application system, handle more access requests, reduce latency, and achieve the overall performance of high concurrency and high load.
Of course, the processing of load balancing is not a simple average distribution, but depends on the actual scheduling diversion algorithm. The algorithm involves the thinking of the developer and the actual situation of the production environment.
2.5.2 High availability Cluster
Improve the reliability of the application system, reduce the main outage time, ensure the continuity of service, and achieve the effect of high availability fault tolerance.
The working mode of HA (high availability) includes duplex mode and master-slave mode. This involves the idea of "decentralization" and "centralization", and the MHA introduced in the previous article is a typical master high-availability cluster architecture model, except that we use the MySQL database to build the highly available architecture.
2.5.3 High performance computing cluster
High Performance Computer Cluster, a high-performance computing cluster, improves the CPU computing speed of the application system, expands hardware resources and analysis capabilities, and obtains the high-performance computing power equivalent to large and supercomputers.
The high performance of high-performance computing cluster depends on "distributed computing" and "parallel computing". It integrates the CPU, memory and other resources of multiple servers through special hardware and software to realize the computing power that only mainframe computers have.
At present, load balancing cluster is the most widely used cluster type in enterprises. The load scheduling technology of the cluster has three working modes: address translation-NAT, IP tunnel-ip Tunnel, and direct routing-Directing Route.
Let's introduce these three modes one by one.
Third, load balancing cluster working mode 3.1NAT mode
Address translation-Network Address Translation. We analyze the pattern in combination with the following figure:
According to the above structure, we do not consider shared storage for the time being. (the next article will give a detailed description of the architecture process and configuration process of this pattern, using NFS as shared storage.)
Let's first look at the solid part, that is, the part where the service is requested on the client side.
1. The client requests the server. For the customer, the target IP address for direct access cannot be the following three or more real servers (Real Server), but the LVS load scheduling server (of course, the server can also be a real server (equivalent to multiple jobs), depending on your own ideas and needs. Generally speaking, we use it as a gateway on the load scheduler, so it has (at least) two network cards and different network segments. On this server, we need to carry out NAT address translation, generally through the method of ip address mapping to achieve the function of data request and data response. Of course, this requires us to understand the principle and setting method of NAT.
two。 The request arrives at the load scheduling server and carries out related processing to assign the data to tasks according to the set scheduling algorithm.
3. The real server that responds to the scheduling algorithm will start to perform its own tasks and return relevant data, while the gateways of all real servers point to the load scheduler, map the ip address according to the NAT principle, and send the data from the external network port to the client.
Throughout the process, the client is not clear about the internal structure of the real server, and in fact it does not need to know.
The most typical features of this model are:
Both data request and data return need to go through the load scheduling server (load balancer/Director).
Then in the high-load application scenario, the load scheduling server in this mode becomes the bottleneck of service performance. If such a situation occurs, there must be a corresponding solution. Next we will introduce the other two modes-- TUN mode and DR mode.
3.2TUN mode
This mode is IP Tunnel mode, or TUN mode for short, and adopts open network structure. The load scheduler serves only as an access entry for the client, and each node responds directly to the client through its own Internet connection instead of going through the load scheduler.
The server nodes are scattered in different locations in the Internet, have independent public network ip addresses, and communicate with the load scheduler through a dedicated IP tunnel.
As shown in the following figure:
The core idea of IP tunneling principle is: based on the technology of encapsulating one IP message in another IP message, so that the data packet whose target is one IP address can be encapsulated and forwarded to another IP address.
Therefore, IP tunneling technology is also called IP encapsulation technology (IP encapsulation). IP tunnels are mainly used for mobile hosts and virtual private networks (Virtual Private Network), where tunnels are statically established. There is an IP address at one end of the tunnel and a unique IP address at the other end.
According to the load of the server, the scheduler dynamically selects a server, encapsulates the request message in another IP message, and then forwards the encapsulated IP message to the selected server. After receiving the message, the server first unencapsulates the message with the original destination address of VIP. The server finds that the VIP address is configured on the local IP tunnel device, so it processes the request, and then returns the response message directly to the customer according to the routing table.
The typical features of this model are:
In addition to the public network IP address of the load dispatching server, the back-end server and its gateway are also public network IP addresses.
The result is that this model is very undesirable in terms of security, as well as the cost of purchasing addresses and management. So, DR mode arises at the historic moment.
3.3DR mode
DR mode, direct routing mode. The semi-open network structure is adopted, which is different from TUN in that each node server is not scattered in different places, but in the same physical network as the scheduler. This also reduces the burden on the server.
As shown in the following figure:
The advantage of this mode is that it not only solves the problems existing in TUN mode, but also because the load scheduler connects with each node server through the local network, there is no need to establish a dedicated IP tunnel.
So, we may have a problem: since the load scheduler and the node server are in the same physical network, we can think of it as a local area network, so doesn't this lead to a broadcast storm?
Answer: this is a very good question, in fact, in our real configuration process, for DR mode, we need to turn off the ARP feature. We will introduce and explain how to close through the actual case configuration in a later article.
IV. Summary of LVS load balancing cluster
This paper mainly explains the principle of the three working modes of LVS load balancing cluster, including some terms that may not be understood by beginners, such as: cluster, load balancing and so on. Only when we understand the principles of the methods developed by our predecessors to achieve the relevant functions, can we have a good understanding and deepen our understanding in practice.
After that, the above NAT mode and DR mode will be configured by actual case simulation. Thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.