The concept of "go" clusters and load balancing

Source: Internet
Author: User

Cluster (Cluster)
The so-called cluster refers to a set of independent computer systems consisting of a loosely coupled multiprocessor system, between them through the network to achieve inter-process communication. Applications can deliver messages over network shared memory for distributed computers.

Load balancer (Load Balance)
Network Load Balancing is a dynamic equalization technique, which analyzes the data packets in real time, grasps the data traffic condition in the network, and distributes the tasks reasonably and evenly. This technology, based on the existing network architecture, provides an inexpensive and efficient way to extend server bandwidth and increase server throughput, enhancing network data processing capabilities and improving network flexibility and availability.

Characteristics:

(1) High reliability (HA). With the cluster management software, when the primary server fails, the backup server can automatically take over the work of the primary server and switch the past in time to realize uninterrupted service to the users.
(2) High Performance Computing (HP). That is to make full use of the resources of each computer in the cluster to realize the parallel processing of complex operations, which is usually used in the field of scientific computing.
(3) Load balancing (load Balance). Load balancing is one of the cluster functions. That is, the load pressure is allocated to each computer in the cluster according to some algorithm, in order to relieve the pressure of the primary server and reduce the hardware and software requirements of the primary server.

Load balancing is the assignment of compute requests to a cluster to balance the compute load of computers in the cluster.

Load Balancing has two implications:
1: A large amount of concurrent access or data traffic is shared on multiple node devices, which reduces the time the user waits for a response.
2: A single heavy load operation is divided into multiple nodes of the device to do parallel processing, each node device processing end, the results are summarized, returned to the user, the system processing capacity has been greatly improved. Implementation can be divided into:
(1) Server Software-based cluster load balancing. (implemented on the server.) )
(2) Nat cluster load balancing (on a fire wall, or on a switch). )
(3) DNS-based cluster load balancing (implemented on DNS servers). )
(4) Can also use the ISA firewall to achieve cluster load balancing, but need to have ISA Server I think the feasibility is not small.

Server Software-based cluster load balancing
Microsoft's Products 4 Clustering technologies:
1:microsoft Cluster Service (MSCS)
2: Network Load Balancing (NLB)
3: Component Load Balancing (CLB)
4:application Center (Application load Balancing)
Linux Cluster Technology: LVS (Linux virtualserver) LVs modified and increased the Linux kernel so that the Linux kernel would be recompiled. Package name linux-2.4.20-ipvs-*.*.*.patch.gz

structure and characteristics of LVS system
1. Linux Virtual Server: for short, LVs. It is a Linux-based server cluster solution initiated and led by a Linux programmer in China, Zhangwensong, whose goal is to create a system with good extensibility, high reliability, high performance and high availability. Many commercial cluster products, such as Redhat's piranha, Turbo Linux turbo cluster, etc., are based on the core code of LVS.
2. Architecture: The server cluster system built with LVS is transparent from the architecture, and the end user only senses a virtual server. Physical servers can be connected across a high-speed LAN or across a WAN. The most front-end is the load balancer, which distributes the various service requests to the subsequent physical servers, making the entire cluster behave like a virtual server serving the same IP address.
3. Three modes of LVS working principle and advantages and disadvantages: Linux Virtual server is mainly implemented on the load balancer, the load balancer is a 2 LVS patch. 2. Linux system for the X version of the kernel. The LVS patch can be added to the kernel by recompiling the kernel, or it can be inserted into the current kernel as a dynamic module.
The load balancer can run in the following three modes:
(1) Virtual server via NAT (Vs-nat): Use address translation to implement a virtualized server. The address translator has a legitimate IP address that can be accessed by the outside world, and it modifies the address of the egress packets from the private network. The outside looks like the packet comes from the address converter itself, and when the outside packet is sent to the converter, it can determine which node of the intranet the packet should be sent to. The advantage is that the IP address is saved, the interior can be camouflaged, and the disadvantage is inefficient because the traffic that is returned to the requester passes through the converter.
(2) Virtual server via IP tunneling (vs-tun): Use IP tunneling technology to implement a virtualized server. This approach is a forwarding mechanism that is available when the nodes of the cluster are not on the same network segment, and is the method of encapsulating the IP packets in other network traffic. For security reasons, you should use a VPN in tunnel technology or use a leased line. The services that a cluster can provide are TCP/IP-based Web services, mail services, news services, DNS services, proxy servers, and so on.
(3) Virtual server via direct Routing (VS-DR): Use direct routing technology to implement a virtualized server. This method can be used when the computer participating in the cluster and the computer that is the control management are in the same network segment, and the control-managed computer is sent directly to the node participating in the cluster when the request packet is received. The advantage is that the traffic returned to the customer does not go through the control host, and the speed is low.
Load balancing with four servers as an example:

Installing the configuration LVs
1. Prepare before installation:
(1) First of all, the LVS does not require uniform server specifications in the cluster, instead, you can adjust the load allocation policy according to the different configuration and load conditions of the server, and make full use of each server in the cluster environment. As the following table:
SRV Eth0 eth0:0 Eth1 eth1:0
VS1 10.0.0.1 10.0.0.2 192.168.10.1 192.168.10.254
Vsbak 10.0.0.3 192.168.10.102
Real1 192.168.10.100
Real2 192.168.10.101
Where 10.0.0.2 is the IP that the user is allowed to access.
(2) In these 4 servers, VS1 acts as a virtual server (that is, a load balancing server) and is responsible for forwarding the user's access requests to the REAL1,REAL2 within the cluster, which are then processed by Real1,real2 respectively. Client tests the machine for clients and can be any operating system.
(3) All OS is redhat6.2, where VS1 and Vsbak core is 2.2.19, and patch Ipvs package, all real server subnet mask are 24-bit, VS1 and Vsbak 10.0.0. The network segment is 24 bits.
2. Understanding the relevant terminology in LVS
(1) Ipvsadm:ipvsadm is a user interface for LVS. Compile and install Ipvsadm on the load balancer.
(2) Scheduling algorithm: LVs load balancer has the following scheduling rules: Round-robin, referred to as rr;weighted Round-robin, referred to as WRR; each new connection is assigned to each physical server in turn. least-connected, abbreviation lc;weighted least-connected, abbreviation WLC, each new connection is assigned to the least burdensome server.
(3) Persistent client connection, referred to as PCC, (continuous client connection, kernel 2.2.10 version is supported later). All clients from the same IP will remain connected to the same physical server. The timeout period is set to 360 seconds. PCC is set up for the HTTPS and cookie services. Under this scheduling rule, after the first connection, all subsequent connections from the same client (including from other ports) will be sent to the same physical server. But this also poses a problem, because about 25% of the Internet may have the same IP address.
(4) Persistent port connection scheduling algorithm: in kernel 2. 2. After version 12, the PCC function has evolved from a scheduling algorithm (you can choose different scheduling algorithms: RR, WRR, LC, WLC, PCC) into a switch option (you can make RR, WRR, LC, WLC with PCC properties). When set, Ipvsadm defaults to the WLC algorithm if you do not select the scheduling algorithm. Under the persistent Port Connection (PPC) algorithm, the connection assignment is port-based, for example, 80 ports and 443 port requests from the same terminal will be assigned to different physical servers. Unfortunately, if you need to use cookies on the website will be a problem, because HTTP is using 80 port, however, cookies need to use 443 port, this method, it is likely that the cookie is not normal situation.
(5) Load Node Feature of Linux Director: Let load balancer also handle the users request.
(6) IPVS connection synchronization.
(7) ARP problem of Lvs/tun and LVS/DR: This problem exists only at lvs/dr,lvs/tun time.
3. Configuring instances
(1) Installation of the required packages and packages:
I. piranha-gui-0. 4. 12-2*. RPM (GUI interface cluster setting tool);
II. piranha-0. 4. 12-2*. rpm
III. Ipchains-1. 3. 9-6lp*. RPM (erecting NAT).
Get the kit or mount to the CD and go to the RPMs directory for installation:
# RPM-UVH piranha*
# RPM-UVH ipchains*
(2) Real server group:
A server that truly provides services, such as a Web server, is configured as an internal virtual domain in the form of a NAT, and is set up as a client-side domain in a generic virtual domain: 192.168.10.0/24 is used as a local network for virtual IP.
A. Set Network card IP
Real1:192.168.10.100/24
Real2:192.168.10.101/24
B. Each server points the default gateway to 192.168.10.254. 192.168.10.254 is the only external channel of the domain, set on virtual server, so that the domain in and out of the network must pass through virtual server.
C. Each server turns on the httpd feature for the Web Server service, which allows you to place pages of different content on each real server, which can be viewed by the browser for reading pages to each real server.
D. Each server turns on RSTATD, sshd, Rwalld, Ruser, rsh, rsync, and gets the same lvs.conf file from vSERVER.
(3) Virtual server:
Role in the guidance of the external host, full-time responsible for packet forwarding, not provide services, but because in the NAT type must be in and out of the package to rewrite, so the burden is also heavy.
A.ip settings:
External eth0:ip:10.0.0.1 eth0:0: 10.0.0.2
Internal eth1:192.168.10.1 eth1:0: 192.168.10.254
In the case of NAT, only virtual server has a real Ip,real server group that is through virtual server.
B. Set NAT function
# echo 1 >; /proc/sys/net/ipv4/ip_forward
# echo 1 >; /proc/sys/net/ipv4/ip_always_defrag
# Ipchains-p Forward MASQ
C. Set piranha into X-window (you can also edit the/ETC/LVS.CF directly)
a). Executive panel System Piranha
b). Set "Overall Configuration" (Global Settings) Master LVS Server host ip:10.0.0.2, select Network address translation (default) NAT path name: 192.168.10.254, Nat path device: eth1:0
c). Set Virtual server (Vsan Servers) Add Edit Virtual Server section: (Virtual Server) name: (arbitrary name); application: HTTP; protocol: TCP; connection: 80; Address: 10.0. 0.2; device: eth0:0; re-entry time: 180 (preset); Service delay: 10 (preset); Load monitoring tool: Ruptime (preset); Scheduling strategy: Weighted least-connections; Persistence: 0 (preset); Persistent masking: 255.255.255.255 (preset); Press activate: Live server section: (real Servers); add Edit: Name: (arbitrary name); address: 192.168.10.100; Weight: 1 (Preset) Press activate
Another real server ibid, address: 192.168.10.101.
d). Control/Monitoring (controls/monitoring) Control: Piranha function activation and stop, the above content setting can press the Start button to activate Piranha. Monitor: Display ipvsadm settings routing table content can be updated immediately or regularly.
(4) Configuration of the backup host (HA)
Single Virtual server cluster architecture Virtual Server is a big burden, providing another host for redundancy, to avoid virtual server failure and to terminate the service work; Backup hosts are ready and virtual Server Mutual Detection
A. Backup host:
Eth0:ip 10.0.0.3
Eth1:ip 192.168.10.102 also need to install piranha,ipvsadm,ipchains and other kits
B. Turn on the NAT function (as described above).
C. Set on the virtual server (10.0.0.2) host.
a). Perform piranha redundancy;
b). Press "Activate redundancy";
Redundant LVS server ip:10.0.0.3;heartbeat interval (seconds): 2 (Preset)
Suppose to be in the ... Seconds to enter dead state: 5 (preset); Heartbeat port: 539 (Preset)
c). Press "Apply";
D). To the Control/monitoring page, press "Add pulse deamon at current execution level" and press "start";
e). The monitor presses "Automatic Update" so that the routing table set by Ipvsadm is visible in the window, and the real server online case is displayed dynamically, and the host disappears from the Watch window if real server fails.
D. Activate the Pulse daemon (Execute #/etc/rc.d/init.d/pulse start) of the backup host.
At this point, the HA function has been activated, the backup host and virtual server by the Pulse Daemon timed mutual inquiry, one but virtual server failure, the backup host is immediately activated instead; to Virtual server Return to virtual server as soon as it is up and running.

LVS Test
After the configuration steps above, the LVS can now be tested, with the following steps:
1. Run/ETC/LVS/RC.LVS_DR on the Vs1,real1,real2 respectively. Note that the/etc/lvs directory above the Real1,real2 is VS2 output. If your NFS configuration is not successful, you can also copy the/ETC/LVS/RC.LVS_DR on the VS1 to Real1,real2 and run it separately. Make sure that Apache above Real1,real2 is up and allows telnet.
2. Test Telnet: Running Telnet 10.0.0.2 from client, if you see the following output after login, the cluster has already started to work: (assuming that you are logged in as a guest user)
[Guest@real1 guest]$--instructions are already logged on to the server real1.
A Telnet window is opened, and when you log in you will notice that the system prompt changes to:
[Guest@real2 guest]$--instructions are already logged on to the server Real2.
3. Test http: Run IExplore from client http://10.0.0.2
Because the test pages are different on the Real1 and Real2, the pages that are displayed will vary after several logons, which means that the real server is already working properly.



Base-to-NAT cluster load balancing (on a fire wall, or on a switch. )
NAT (network address translation) simply translates an IP address into another IP address. Typically used for internal addresses with legitimate conversions. It is suitable for resolving the Internet IP address tension, do not want to let the network outside know the internal network structure and so on.
NAT Load Balancer maps an external IP address to multiple internal IP addresses, dynamically converting each connection request to an internal server address, and connecting the external connection request to the server where the address is converted, thus achieving load balancing purposes.
DNS-based cluster load balancing (implemented on DNS servers.) )
DNS load Balancing technology is to configure multiple IP addresses for the same host name in the DNS server, and when answering DNS queries, the DNS server will return different resolution results in sequence with the IP address of the host record in the DNS file, directing client access to different machines. Enables different clients to access different servers, thus achieving load balancing purposes.
DNS load balancing uses a simple round-robin load algorithm, can not distinguish between server differences, not reflect the current state of the server, can not be a better performance of the server multi-allocation request.

The concept of "go" clusters and load balancing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.