I. Introduction to the Cluster
What is a cluster
A cluster of computer clusters is a computer system that works closely together through a loosely integrated set of computer software and/or hardware connections. In a sense, they can be seen as a computer. A single computer in a clustered system is often called a node, usually connected over a local area network, but there are other possible ways of connecting. Cluster computers are often used to improve the computational speed and/or reliability of a single computer. In general, clustered computers are much more expensive than a single computer, such as a workstation or a supercomputing machine.
A cluster is a group of independent computers that combine a combination of network connections to complete a task together
The location of LVS in the Enterprise architecture:
The above framework is only one of many enterprises inside. The Green Line is where the user accesses the requested data flow. User-->lvs Load Balancing server--->APAHCE server--->mysql server &memcache server & shared storage server. And our MySQL, shared storage can also use LVS to load balance.
---------------Summary-------------------------
Cluster: A group of independent computers that form a computer system through a high-speed network, each of which is a stand-alone server running its own process. For network users, the backend of the website is a single system, together to provide users with system resources, system services.
-------------------------------------------
Why to use a cluster
The characteristics of the cluster
1) High performance performance. Some require very strong computational processing capabilities such as weather forecasts, nuclear tests, and so on. This is not a few computers can handle. It will take thousands of units to do the work together.
2) Price validity
Usually a set of system cluster architecture, only need a few or dozens of server host can, and move on Hundred King's dedicated super computer has a higher price/performance ratio.
3) Scalability
When the load pressure of the server increases, the system can expand to meet the requirements without reducing the quality of service.
4) High Availability
Although some hardware and software fail, the service of the entire system must be run 7*24 hours.
The advantages of the cluster
1) Transparency
If a part of the server down the business is not affected, the general coupling is not so high, the dependency relationship is not so high. For example, NFS server downtime, the others can not be mounted, so the dependency is too strong.
2) High Performance
The number of visits is increased and can be easily extended.
3) Manageability
The entire system may be physically large, but it is easy to manage.
4) Programmability
In the cluster system, easy to develop applications, the portal will require this.
Cluster classification and the characteristics of different classifications
The computer cluster architecture is generally divided into the following categories in terms of function and structure:
1) Load Balancing cluster (loadbalancingclusters) short LBC
2 High Availability cluster (high-availabilityclusters) short HAC
3 high-performance Computing Cluster (high-perfomanceclusters) for short HPC
4) Grid computing (gridcomputing)
The network is generally considered to have three, load-balanced and highly available clustering of our Internet industry common cluster architecture.
(1) Load Balancing cluster
The load Balancing cluster provides a more practical and cost-effective system architecture solution for the enterprise. Load-balancing clusters can allocate the load pressure of many customer-focused requests to the computer cluster as evenly as possible. The customer request load typically includes the degree of application processing load and network traffic load. Such systems are ideal for providing services to a large number of users using the same set of applications. Each node can bear the load pressure of certain access requests, and can realize the dynamic allocation between the nodes in order to achieve load balancing.
When load balances run, customer access requests are typically distributed to a backend group of servers through one or more front-end load balancers to achieve high performance and high availability across the system. This computer cluster is sometimes called a server farm. Common high-availability clusters and load-balancing clusters use similar technologies, or have both high availability and load balancing features.
The function of load-balanced cluster
1) Sharing of access traffic (load Balancing)
2 Maintain business continuity (high availability)
(2) High Availability cluster
In general, when any node in the cluster fails, all tasks on the node are automatically transferred to the other normal nodes, and this process does not affect the operation of the entire cluster and does not affect the delivery of the business.
Similar to two or more of the same nodes running in a cluster, when a primary node fails, other nodes that are from the node take over the tasks on the master node. A node can take over the resource (IP address, schema identity, etc.) of the master node, at which point the user does not find that the object providing the service is transferred from the primary node to the node.
The role of high availability clusters: When one machine goes down and another takes over. The more common high availability cluster open source software is: keepalive,heardbeat.
(3) High Performance computing cluster
The High performance computing cluster uses different computing nodes to allocate computing tasks to clusters to improve the computational ability, so it is mainly applied in the field of scientific computation. The more popular HPC uses a Linux operating system and some other free software to perform parallel operations. This set of cluster configurations is often referred to as the Beowulf cluster. Such clusters typically run specific programs to perform hpccluster parallelism. Such programs typically use specific runtime libraries, such as MPI libraries designed for scientific computing.
HPC clusters are particularly suitable for computing operations in which a large amount of data traffic occurs between compute nodes, such as the intermediate results of a node or the results of other nodes.
Common cluster software and hardware
Common open source cluster software: lvs,keepalived,haproxy,nginx,apache,heartbeat
Common business cluster hardware is: F5,NETSCALER,RADWARE,A10, etc.
Second, the LVS load Balanced cluster introduction
The role of load Balancing clusters: To provide a low-cost, efficient, transparent way to extend the load bandwidth of network equipment and servers, increase throughput, enhance network data processing capabilities, improve network flexibility and availability.
1 The single computer can not withstand large-scale concurrent access or data traffic sharing to multiple node devices to deal with, reduce the user waiting for response time, improve user experience.
2 The operation of a single heavy load can be divided into multiple node devices to do parallel processing, after each node equipment processing, the results are summarized, returned to the user, the system processing capacity has been greatly improved.
3 7*24 hours of service to ensure that any one or more equipment node equipment downtime, can not affect the business. In a load-balancing cluster, all computer nodes should provide the same service, and cluster load balancing gets all the requests for the service.
About LVS
LVS is a Linux virtual server, the abbreviated Linux VM, is a virtual server cluster system, can be unix/linux platform to achieve load-balanced cluster functions. The project was organized by Dr. Zhangwensong in May 1998.
The following is the 4 articles from the website of LVs: (In very detail, I think it is more authentic to see the official documents.) )
Http://www.linuxvirtualserver.org/zh/lvs1.html
Http://www.linuxvirtualserver.org/zh/lvs2.html
Http://www.linuxvirtualserver.org/zh/lvs3.html
Http://www.linuxvirtualserver.org/zh/lvs4.html
The history of Ipvs
As early as the 2.2 kernel, Ipvs was already in the form of a kernel patch.
Starting with version 2.4.23 Ipvs Software is a collection of kernel patches that are commonly used to incorporate into the Linux kernel.
Since 2.4.24 Ipvs has become part of the Linux official standard kernel
From the above figure can be seen Lpvs is working in the kernel layer, we can not directly operate Ipvs,vs load Balancing scheduling technology is implemented in the Linux kernel. Therefore, it is called a Linux virtual server. When we use this software to configure LVS, we cannot directly configure the Ipvs in the kernel, but we need to use Ipvs management tools Ipvsadm for management. LVS can also be managed through keepalived. A brief description of the LVS architecture and working principle
The LVS cluster load balancer accepts requests from all inbound clients of the service, and then determines which cluster node to process the request for the reply client according to the scheduling algorithm.
LVS virtual Server system as shown in the following illustration, a group of servers are interconnected via a high-speed LAN or geographically distributed WAN, which has a load scheduler (load balance) before this set of servers. The load scheduler is responsible for dispatching the customer's request to the real server. The structure of this group of server clusters is transparent to the user. Customer access to the cluster system is just like accessing a high-performance, highly available server. The client program is not affected by the server cluster and does not make any changes.
For example: We go to a restaurant to order, the customer just order with the waiter. There is no need to know exactly how they are assigned to work, so they are transparent to us internally. At this time the waiter will be in accordance with certain rules of his hand, assigned to other personnel to go up. This waiter is the load balancer (LB) and the latter is the server cluster.
Below is the official website provides the structure chart:
The basic work process of LVS
The customer sends the request to the load balancing server. The load balancer accepts the customer's request and then decides which node server to send the request based on the LVS scheduling algorithm (8 kinds). Then according to their working mode (3) to see how these customer requests sent to the node server, the node server should be how to send response packets back to the client.
Well, then we just have to understand the LVS 3 working mode, 8 kinds of scheduling algorithm can be.
LVS Three modes of operation:
1) Vs/nat mode (network address translation)
2) Vs/tun mode (tunneling)
3) Dr Mode (Direct routing)
1, Nat mode-network address translation
VirtualServer via network address translation (Vs/nat)
This is through the network address translation method to implement the scheduling. First, the Scheduler (LB) receives the client's request packet (the requested destination IP is the VIP), and according to the dispatch algorithm, determines which backend real server (RS) to send the request to. The dispatch then changes the destination IP address and port of the request packet sent by the client to the IP address (RIP) of the back-end real server, so that the real server (RS) can receive the client's request packet. After the real server responds to the request, view the default route (we need to set the default route for Rs to the LB server in NAT mode). After the response to the data packages sent to LB,LB and then received the response packet, the source address of the package changed to virtual address (VIP) and then sent back to the client.
Scheduling process IP Packet Detail diagram:
Schematic Sketch:
1 Client request data, target IP for VIP
2 Request data arrives at LB server, LB modifies destination address to rip address and corresponding port according to scheduling algorithm (this RIP address is based on scheduling algorithm). ) and record the connection in the connection hash table.
3 The packet arrives at Rs server webserver from the LB server, and then webserver responds. The webserver gateway must be lb, and then return the data to the LB server.
4 received the return of RS data, according to the hash table to modify the source address vip& target address CIP, and the corresponding port 80. The data then arrives at the client from Lb.
5 The client can only see VIP\DIP information when they receive it.
Nat Mode pros and Cons:
1, the NAT technology will request the message and the response of the message needs to rewrite the address through LB, so the Web site traffic is relatively large when the LB load-balancing scheduler has a larger bottleneck, the general requirements of the most can 10-20 nodes
2, just need to configure a public network IP address on the LB can be.
3, each internal node server gateway address must be the dispatcher LB's intranet address.
4, Nat mode supports the conversion of IP address and port. That is, the port that the user requests and the port of the real server can be inconsistent.
2, Tun Mode
Virtual server via IP tunneling mode: When Nat mode is used, because the message of request and response must be rewritten through the dispatcher address, the scheduler processing ability becomes the bottleneck when the client requests more and more. To solve this problem, the dispatcher forwards the requested message to the real server through an IP tunnel. The real server returns the processed data directly to the client. In this way, the dispatcher only processes the request inbound message, because the General Network Service response data is much larger than the request message, the maximum throughput of the cluster system can be increased 10 times times after adopting the Vs/tun mode.
Vs/tun's work flow chart looks like this, unlike the NAT mode, it transfers between lb and RS without overwriting the IP address. Instead, the customer request package is encapsulated in an IP tunnel, and then sent to the RS node server, the node server receives after the IP tunnel, after the response processing. and directly to the packet through their own extranet address to the customer without passing through the LB server.
Tunnel Principle Flow chart:
Schematic diagram Process brief:
1 customer request packet, target address VIP sent to lb.
2 lb receives the customer request package for IP tunnel encapsulation. That is, the original header plus the IP tunnel header. And then send it out.
3 RS node server according to IP tunnel header information (at this time, another logical stealth tunnel, only the LB and Rs understand) received the request package, and then unlock the IP tunnel header information, get the customer's request package and response processing.
4 after the response processing, RS server uses its own out of the public network of lines, the response data packages sent to the client. The source IP address or the VIP address. (RS node server needs to be configured in the local loopback interface VIP, follow-up will Speak)
3, Dr Mode (direct routing mode)
Virtual server via direct routing (VS/DR)
Dr Mode is to send the request to the real server by overwriting the destination MAC address of the request message, and the processing result of the real server response is returned directly to the client user. As with Tun mode, Dr Mode can greatly improve the scalability of the cluster system. Moreover, Dr Mode does not have the overhead of IP tunneling, nor is it necessary to support the IP Tunneling Protocol requirements for real servers in the cluster. But requires that the scheduler lb and the real server RS have a network card connected to the same physical network segment and must be in the same LAN environment.
Dr Mode is one of the more models used by the Internet.
Dr Mode schematic diagram:
The principle process of Dr mode is briefly described:
The work flow chart of the VS/DR mode is shown in the diagram above, and its connection scheduling and management is the same as in Nat and Tun, and its message forwarding method differs from the first two. Dr Mode routes the message directly to the target real server. In DR Mode, according to the load of each real server, the number of connections, and so on, dynamically select a server, do not modify the target IP address and destination port, also does not encapsulate IP packets, but the request message data frame of the target MAC address to the real server's MAC address. The modified data frame is then sent on the LAN of the server group. Because the MAC address of the data frame is the MAC address of the real server, and it is on the same LAN. So according to the communication principle of LAN, the real reset is to be able to receive the packet sent by Lb. When the real server receives the request packet, unlock IP header to see the target IP is VIP. (At this time only their own IP to meet the target IP will be received, so we need to be in the local loop excuse above configuration VIP.) Another: Because the network interface will be ARP broadcast response, but the cluster of other machines have this VIP LO interface, the response will conflict. So we need to shut down the ARP response of the LO interface of the real server. Then the real server makes the request response, then sends the response packet back to the customer according to its routing information, and the source IP address is the VIP.
Dr Mode Summary:
1. Implement forwarding by modifying the packet's destination MAC address on the dispatcher lb. Note that the source address is still CIP and the destination address is still the VIP address.
2, the requested message through the scheduler, and RS response to the processing of the message without having to go through the scheduler lb, so the concurrent access to large use efficiency is high (and NAT mode ratio)
3. Because Dr Mode is forwarded through MAC address rewriting mechanism, all RS nodes and scheduler lb can only be in a local area network
4, RS host needs to bind VIP address on the LO interface, and the need to configure ARP suppression.
5, RS node's default gateway does not need to be configured into LB, but directly configured for the superior routing gateway, can let the RS directly out of the net can.
6, because the DR Mode scheduler only to do the MAC address rewrite, so the scheduler lb can not overwrite the target port, then RS server will have to use the same port with the VIP service.
Official three kinds of load balancing technology comparison summary table:
Working mode |
Vs/nat |
Vs/tun |
Vs/dr |
Real server (node server) |
Config Dr GW |
Tunneling |
Non-arp Device/tie VIP |
Server Network |