[] 1. load balancing load balancing Introduction

Part from:  https://www.cnblogs.com/lizhaoxian/p/11479335.html

        https://www.cnblogs.com/zhaiyf/p/9051694.html

I. Overview

1. Introduction: load balancing cluster, Load Balance cluster, is a kind of traffic on the network distributed to each node to reduce the pressure on the server, provide a way to better service to the client.

2, appear Background: As business increases, the flow rate increases, high concurrency, increasing pressure on the server, in order to solve this problem, one of which is a single server expansion, such as increasing CPU, memory, switching to high-performance disk, but this process is complicated and costly, will affect the existing business, the other is load-balanced cluster, add and delete backend nodes completely transparent for users.

3, meaning: to expand the bandwidth of network devices and servers to increase throughput, enhance network data processing capability, increase flexibility and availability of the network.

4, common hardware and software

Common load balancing hardware: F5, deeply convinced, Cisco, Barracuda, Netscaler, etc. (but stable money, and professional technical support, independent of the system)
Common load balancing software: Lvs, nginx, haproxy, Piranha, heartbeat and so on. (Depends on the system, increasing system overhead, but the configuration is simple, flexible operation. Ngnix haproxy are seven and load balancing, the LVS is four load balancing)
 

Two, four and seven load balancing load balancing

Load balancing has two, three, four, seven. Common for the four and seven. It is to establish a particular user access and server connection to exchange data packets to achieve, if you do load balancing in the third layer of the network layer, it will lose the semantics of "connection" of. Object-oriented software load should be an established user connection, rather than a solitary IP packet.
 
Load balancing is based on four IP + port load balancing , that is mainly through the message destination address and port, plus a server selection method (algorithm) load balancing device settings, determine the final choice of the internal server.
Seven load balancing is based on a virtual host URL or IP load balancing , that is, mainly through meaningful application layer content message, plus the choice of server load balancing device mode settings to determine the final choice of the internal server .
Advantages and disadvantages of comparison: four good performance, more than seven configurable, can be forwarded according to the message content.
 
Simple to understand what software load balancing.
①. The so-called hierarchical load balancing, are based on the model of the network is. Four is the IP-based load balancing and port, seven load balancing is based on the application of information such as the URL. So simply put four load balancing is through IP and port to receive requests and then distributed to the real server, seven are receiving requests by URL or host name, and then distributed to the real server.
②. Realization is based on four of seven on is achieved, there can be no four-seven. On the seventh floor can do many things, such as a mobile phone or PC may be browser based on seven categories of distinction, WEB server will be divided into two groups, the special mobile phone terminal site.
③. The client, the client seems to be the same host access. In fact, in order to have a better user experience, starting from the intelligent DNS, based on the client IP source from the domain name resolves to a client or a server closest access to the most rapid one server, but the contents of these clients are not feel the client felt only visit the site soon.
 

Third, the three commonly used open source software load balancer features

1、LVS

1. First, it is based, load-resistant capability of the network protocol layers 4, the hardware requirements for the server in addition to the card, not too many other requirements;
2. Configure relatively low, which is a drawback is also an advantage, because too many things can no configuration, greatly reducing the chance of human error;
3. broad range of applications, not only do load balancing for web services, you can also do load balancing for other applications (such as mysql);
4. LVS IP architecture, there is a virtual concept, IDC need to do more than apply an IP virtual IP.

2, Nginx load balancer

1. Work on the seven layers of the network, you can do some diversion policy for http applications, such as for the domain name, the directory structure;
2. Nginx relatively simple to install and configure, test more convenient;
3. You can also assume a high load pressure and stable, generally support more than a million times on concurrent;
4. Nginx port failure is detected by the internal server, such as web server processing according to the status code returned, to time out, and will return an error to resubmit the request to another node, but which do not support the drawback is detected url ;
5. Nginx asynchronous processing request can help reduce the load on the server node;
6. Nginx supports http and Email, so much smaller in scope above;
7. There are three default scheduling algorithms: polling, weight and ip_hash (can solve the problem of keeping the session), also supports third-party fair and url_hash such as scheduling algorithms;

3、HAProxy

1. HAProxy 7 is working on the network layer;
2. Session holding support, Cookie guide the like;
3. Support url detect the back-end server detects the problem will be a good help;
4. Support load balancing algorithms: Dynamic Weighted Round Robin (Dynamic Round Robin), the source address hash weighting (Weighted Source Hash), parameters weighted weighting URL and the hash hash (Weighted Parameter Hash);
5. From the purely in terms of efficiency HAProxy more than Nginx has better load balancing speed;
6. HAProxy can load balance Mysql, the rear end of the DB nodes to detect and load balancing.
 

Guess you like

Origin www.cnblogs.com/cmxu/p/12360761.html