Load Balancing LVS cluster details

Source: Internet
Author: User

I. lb-Server Load balancer

A distributor is needed in a server Load balancer cluster. It is called Director, which is located on the middle layer of multiple servers, select a server group from the following server group based on internal locking rules or scheduling methods to respond to requests. The distribution method is based on an algorithm.

Ii. Ha-High Availability

High Availability, as its name implies, means the service availability is relatively high. That is, when we do not go down on a server, our service becomes unavailable, the working mode is to forward a faulty service to a normal server, so that the service will not be interrupted.

Iii. LVS:

LVS: Linux virtual server, which implements simple load balancing on the Linux platform.

Generally, LVS adopts a three-tier structure: Load scheduler, server pool, and shared storage. It works on the layer-4 TCP/IP Protocol. Its forwarding relies on the features of the layer-4 protocol for forwarding. Because the forwarding relies on the features of the protocol for forwarding, therefore, you need to filter the TCP/IP protocol stack in the kernel. As you can imagine, this needs to be done in the kernel module, and such filtering and forwarding rules are defined by the Administrator, therefore, LVS is a two-stage architecture design. In the kernel space, "ipvs" is used, while in the user space, "ipvsadm" is used to define cluster service rules ". This makes it easy to think of iptables.

Three forwarding modes of LVS:

LVS-NAT: Network Address Translation

LVS-DR: Direct routing

LVS-TUN: IP tunneling

VIP: IP address used by Director to provide services to clients

Rip: IP address used by cluster nodes (servers that actually provide services in the background)

Dip: the address that director uses to contact D/rip.

CIP: Public IP address used by the client.

LVS-NAT: ------ extended DNAT

1. All real servers and ctor must be in the same network segment

2. Generally, rip is a private address and is only used for communication between cluster nodes.

3. Director processes both inbound and outbound requests.

4. the gateway of the Real Server must point to the dip

5. Port ing can be implemented (the request port and the port providing services can be inconsistent)

6. Real Server can be any operating system

7. Director easily becomes the bottleneck of system performance.

Packet address conversion process:

S: cip d: VIP -------> Director ------> S: cip d: Rip ------> Real Server ------> S: Rip D: CIP -----> Director -----> S: vip d: CIP

LVS-DR: the user's request goes through ctor, then the real server directly responds to the client any real Server Gateway cannot execute drector

1. The cluster node must be in the same physical network and be forwarded based on Mac.

2. Rip can use a public IP address.

3. Director only processes inbound requests, and the response packet does not pass through Director

4. the gateway of Real Server cannot point to Director

5. Port ing is not supported.

6. Most operating systems can be used for Real Server (ARP broadcast is isolated and multiple IP addresses are supported on the same Nic)

7. Director has far better performance than Nat

Packet address conversion process:

S: cip d: VIP -----> Director ---> S: cip d: Rip -----> Real Server ---> S: vip d: CIP

LVS-TUN: the user's request goes through ctor, then the real server directly responds to the client

1. Real Server and director do not need to be in a physical network segment

2. Rip must not be a private address.

3. Director only processes inbound requests

4. the gateway of Real Server cannot point to Director

5. Port ing is not supported.

6. Only an operating system that supports IP tunneling can be used for Real Server

The network structure is the same as that of DR, But director and Real Server can be transmitted in different networks. Dip -----> VIP is transmitted Based on tunnel, and s: dip D: the rip address.

Iv. LVS scheduling algorithm:

1. static scheduling algorithm:

Rr: round-robin: Round Robin

WRR: Weighted Round-Robin: Weighted Round Robin-calculate the weight of a weight based on the performance distribution.

DH: Destination hashing: target address hashing ----- forward requests from a fixed IP address to the same real server

SH: Source hashing: Source Address hashing

2. Dynamic Scheduling Algorithm: This algorithm sets a scheduling decision based on the distribution algorithm and the load status of the Real Server. Director tracks and monitors whether each connection is in the active state (estableshed)

LC: Least connection: minimum connection ----- monitor the number of active connections and inactive connections of each Real Server, and calculate its current load: Active * 256 + inactive = overhead

Wlc: weighted least connection: weighted least join ------ overhead/weight. Considering the performance of real serverd, the default Cluster Algorithm

Sed: shortest expected delay: the shortest expected latency ---- ignore inactive connections. algorithm: (Active + 1) * 256/Weight = overhead

NQ: Never queue: Never queues ----- direct forwarding without connection

Lblc: locality-based least-connection: based on local minimum connections, dynamic DH Algorithm

Lblcr: locality-based least-connection with replication scheduling: local least-connection with replication, cache is shared

V. ipvsadm

Ipvsadm: 1. Define cluster service, specify VIP, protocol, port, 2. Add rs to cluster service

Usage:

Ipvsadm-A | E-T | u VIP: Port [-s scheduler] [-P [timeout] [-M netmask]

-A: define a new cluster service.

-E: Modify existing cluster services.

-D: delete a cluster service.

-S: Specifies the scheduling algorithm. Options: RR | WRR | LC | wlc | lblc | lblcr | DH | sh | sed | NQ. The default scheduling algorithm is wlc.

-C: Clear

-R: equivalent to restore SADM-restore to restore virtual server rules

-S: equivalent to running SADM-Save to save the Virtual Server rule. The output is in the readable format of the-r option.

-L | L: list the currently defined Cluster services and real servers.

-- Stats: displays both the statistical information and-l.

-- Rate: displays the inbound response rate and-l usage at the same time.

-C: displays the current connection of LVS and the use of-l at the same time.

-N: Do not use reverse resolution and-l at the same time

-Z: clears the counter.

-T -- TCP-Service-Address indicates that the virtual server provides the TCP Service.

-U -- UDP-Service-Address indicates that the virtual server provides UDP services.

-F -- fwmark-service fwmark indicates the service type marked by iptables.

-P -- persistent [timeout] persistent and stable service. This option means that multiple requests from the same customer will be processed by the same real server. The default timeout value is 300 seconds.

Ipvsadm-A | E-T | u VIP: pory-r rip [-G | I | M] [-W weight]

-A: Add Real Server

-E: Modify the Real Server

-G: Specify the LVS working mode as the direct routing mode (also the default LVS mode)

-I: Specify the LVS working mode as tunnel mode.

-M: Specify the LVS working mode as Nat

-W: actual server weight

Ipvsadm-D-T | u service-address-r server-address Delete A Real Server record in a virtual server record

Load Balancing LVS cluster details

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.