Nginx LVS load balancing

1 Introduction

lvs (linux virtual server), linux virtual server, is a virtual four-layer switch cluster system, which realizes user request forwarding according to the target address and target port, does not generate traffic itself, only forwards user requests, and currently has the best load balancing performance With a good cluster system, load balancing achieves good scalability, and the number of nodes can grow to thousands or even tens of thousands. Later, many users participated in the development of LVS auxiliary tools and auxiliary components. The most famous one is keepalived written for LVS by Alexandre. It was originally used to monitor LVS, and then VRRP was added to achieve high availability.

Load scheduler and real server cluster nodes are collectively called LVS. LVS load scheduler (sometimes called load balancer) receives all requests for access to the service cluster and decides which node in the cluster should reply to its request .

1) Load scheduler (director): As the front end of the entire cluster, it mainly distributes user requests to real servers for processing.

2) Real server pool: It is composed of multiple real servers with the same function, providing users with real network services, such as web services, mail services, etc. And the virtual server cluster is a scalable cluster, you can freely add deep real servers and affect the normal operation of the entire cluster in parallel.

3) Shared storage: The function is to allow each user to access the same resources, and the server supports write operations, so it is recommended to use it

The high availability of the LVS cluster, although the LVS load balancing performance is very good, but if the node fails, LVS is not aware of it, so an auxiliary tool around LVS is produced, KeepAlived, which is very good for monitoring and checking compatibility. If RS is a node Hang up, keepalived will remove this node from the management list, and when the node is restored, it will be pulled back to the management list, but at this time the scheduler has the possibility of a single point of failure, so other software must be used to achieve the high level of the scheduler. Available, such as hearbeat.

Official website link: http://linux-vs.org/index.html

2 Common nouns

  • VS: virtual server, virtual server, also called Director
  • RS: real server, real server, node in the cluster
  • CIP: Client IP
  • VIP: virtual IP, the IP used by the director to provide services to the outside world
  • RIP: The server network card IP of the realserver cluster node
  • DIP: The IP used by the director to communicate with RS

3 Three modes

2.1 NAT network address translation mode

Insert picture description here

Principle and applicable scenarios: Relatively speaking, using NAT mode, the configuration is relatively simple, and it is easy to expand, and is suitable for application services that do not respond to a large amount of traffic.

Disadvantages: All requests will go through the LVS scheduler, which can easily trigger bottlenecks.

2.2 TUN IP tunnel mode

Insert picture description here

Principle and application scenario: When requesting, it will be dispatched by the LVS scheduler, and when responding, the server will return the result directly to the client. It is suitable for the situation where the server can be configured with multiple IPs.

Disadvantages: The server needs to be able to directly interact with the server, which is not suitable for machines with a pure intranet.

2.3 DR direct routing mode

Insert picture description here

Principle and applicable scenarios: When requesting, it will be dispatched by the LVS scheduler. When responding, the server will forward the result to the Router, and the router will return the result to the client. It is suitable for multiple machines on the same network segment.

Disadvantages: The LVS scheduler and the application server are in the same network segment, so the cross-network segment application of the cluster cannot be realized.

3 Related information

  • The blog post is not easy, everyone who has worked so hard to pay attention and praise, thank you

Guess you like

Origin blog.csdn.net/qq_15769939/article/details/113624050