Comparison of load balancing technologies

Load Balancing Technology
Load Balancing

1.1 Load Balancing Type
HTTP Redirection, DNS Domain Name Resolution, Reverse Proxy, IP Load Balancing, Data Link Layer Load Balancing

1.2 Load Balancing Algorithm
Random, Round Robin, Weighted Round Robin, Minimum Connections, Minimum Weight Number of connections, source address hashing

1.3 Commonly used load balancing techniques include:
hard solution: F5
software: dubbo, lvs, haproxy, nginx, etc.

Comparative analysis of lvs, haproxy, nginx load balancing
link: http://blog.csdn.net /gzh0222/article/details/8540604


Practice

1.Dubbo application server load balancing (see dubbo for details)
environmentwindows
/Linux/Unix

component
zookeeper cluster (availability)
application server cluster

configuration
load balancing settings

summary
High performance: cluster/load balancing
high availability : Cluster
High Scalability: Cluster/Load Balancing
High Scalability: Dubbo

Cluster:
1. Web Application Cluster:
1.1 Principle: Implementation based on Ali dubbo framework
:
[1] Deploy applications on 3 different physical servers (based on Tomcat) ;
[2] All applications are registered on a zookeeper cluster;

1.2 zookeeper cluster: distributed coordination service cluster

1.3 zookeeper service monitoring center cluster

1.4 test/optimization
case design:
user logs in to the service and makes remote service calls locally;
try: when the main zookeeper shuts down abnormally, whether the service continues to be available (close 1 first Close again 1);
   test method: close one of the zookeepers. Test
    
 discovery:
 1) When the machine has zookeeper, it will first register to the local; test again: close zookeeper2, restart tomcat2, and see if the service will be registered to 1 or 3;
 found The registered address is still 130; Note: If the registered address includes the local machine, the local machine in the cluster will be preferentially selected by default, because the clustered service is used collectively, and the local machine is selected to improve efficiency;
 retest: in the registered address configuration file, do not write This machine will still be written to this machine;
 2) For a cluster composed of three zookeepers, at least 2 are alive (); 
 
 
Try: When the server is stopped, whether the access is abnormal (close 1 and then close 1);
   Test method: 1 The console shows that the login is successful, and the other shows that the login fails; close one of the tests;
observe in the console: the characteristics of the access


Load balancing: the
application realizes load balancing through Dubbo
zookeeper No




Nginx/LVS/HAProxy are currently the three most widely used loads Balance software, I have implemented it in many projects, I have referenced some materials, combined with some of my own experience, and summarized it.

Generally, the use of load balancing is to use different technologies according to different stages as the scale of the website increases. Specific application requirements have to be analyzed in detail:
(1) It is carried out through hardware. Common hardware includes relatively expensive commercial load balancers such as F5 and Array. Its advantage is that there is a professional maintenance team to maintain these services. The disadvantage is that it costs too much,
so For small-scale network services, there is no need to use it for the time being;
(2) Through Linux-based open source free load balancing software similar to Nginx/LVS/HAProxy, these are implemented at the software level, so the cost is very low .
    2.1 For small and medium-sized web applications, for example, if the daily PV is less than 10 million, you can use Nginx; if there are many machines, you can use DNS polling, and LVS consumes a lot of machines;
    2.2 For large websites or important services, And when there are many servers, LVS can be considered.

At present, there are generally more reasonable and popular architecture schemes for website architecture: the
front-end of the web uses Nginx/HAProxy+Keepalived as the load balancer; the back-
end uses the MySQL database with one master and multiple slaves and separation of read and write, and adopts the architecture of LVS+Keepalived.
Of course, the plan should be formulated according to the specific needs of the project. The following are the characteristics and applicable occasions of each.
Reference: http://www.ha97.com/5646.html

1. What is LVS
LVS (Linux Virtual Server) in the end, in fact, it is a cluster (Cluster) technology, using IP load balancing technology and content-based Request Distribution Technology.
The scheduler has a good throughput rate, and transfers the requests to different servers for execution in a balanced manner, and the scheduler automatically shields the failure of the server, thereby forming a group of servers into a high-performance, high-availability virtual server.
The structure of the entire server cluster is transparent to the client, and there is no need to modify the client and server side programs.
For this reason, transparency, scalability, high availability and manageability of the system need to be considered in the design. Generally speaking, the LVS cluster adopts a three-tier structure, and its architecture is shown in the figure:
Reference: http://soft.chinabyte.com/25/13169025.shtml

2. What is Nginx
Nginx is a lightweight Web Server, reverse proxy and email (IMAP/POP3) proxy server, and distributed under a BSD-like protocol. The characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, the concurrency capabilities of nginx are indeed better among web servers of the same type. The
users of nginx websites in mainland China include: Baidu, JD.com, Sina, NetEase, Tencent, Taobao, etc.
In the case of high concurrency of connections, Nginx is a good alternative to Apache servers: Nginx is one of the software platforms often chosen by web hosting business owners in the United States. Response characteristics that can support up to 50,000 concurrent connections
: From the network
[1. Hot deployment]
The separation design of the master management process and the worker worker process enables Nginx to have the function of hot deployment, so it can be continuously serviced 7×24 hours On the premise, upgrade the Nginx executable file. You can also modify configuration files, replace log files, and other functions without stopping the service.
[2. High concurrent connections are possible]
This is a very important feature! With the rapid development of the Internet and the increasing number of Internet users, some large companies and websites need to face high concurrent requests. If there is a server that can withstand more than 100,000 concurrent requests at the peak, it will definitely be favored by everyone.
In theory, the upper limit of concurrent connections supported by Nginx depends on your memory, and 100,000 is far from the cap.
[3. Low memory consumption]
Under normal circumstances, 10,000 inactive HTTP Keep-Alive connections consume only 2.5M of memory in Nginx, which is the basis for Nginx to support high concurrent connections.
[4. Process response requests quickly]
Under normal circumstances, a single request will get a faster response. During peak periods, Nginx can respond to requests faster than other web servers.
[5. High reliability]
Nginx is a highly reliable web server, which is the basic condition for why we choose Nginx. Now many websites are using Nginx, which is enough to show the reliability of Nginx. High reliability comes from the excellent design of its core framework code, the simplicity of module design; and these modules are very stable.
[6. Reverse proxy]
Nginx ("engine x") is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP server. Nginx was developed by Igor Sysoev for the second most visited Rambler.ru site in Russia.
What is a reverse proxy? That is, the proxy server accepts the connection request on the internet, then forwards the request to the server on the internal network, and returns the result obtained from the server to the client requesting the connection on the internet. At this time, the proxy server acts as a server.
The main work of Nginx is reverse proxy. For example, when we send a request to port 80 of a server, the request is first monitored by Nginx, which receives the content of the request and then forwards it to other servers. After processing by other servers The result is sent to Nginx, and finally Nginx returns it to the initial requester.
The most common use of Nginx is as a static resource server, such as caching CSS, JS, html, htm and other files.
We need to filter by file type. For example, jsp is directly processed by tomcat. Because nginx is not a servlet container, it cannot process JSP, and html, js, and css do not need to be processed, and are directly cached by nginx.

Advantages of Nginx Web Server
Nginx is a very high-performance Web and reverse proxy server, it has many very superior features:
In the case of high connection concurrency, Nginx is a good substitute for Apache server: Nginx in the United States is doing One of the software platforms often chosen by web hosting business owners. It can support responses of up to 50,000 concurrent connections, and
Nginx acts as a load balancing server: Nginx can directly support Rails and PHP programs for external services internally, and can also support external services as The HTTP proxy server provides external services. Nginx is written in C, which is much better than Perlbal in terms of system resource overhead and CPU usage efficiency.
As a mail proxy server: Nginx Web server is also a very good mail proxy server (the earliest development of this product One of the purposes is also as a mail proxy server), Last.fm describes a successful and wonderful experience.
Nginx web server is a very simple to install, very concise configuration file (also supports perl syntax), very few bugs server : Nginx is very easy to start, and it can run almost 7*24 uninterrupted, even if it runs for several months without restarting. You can also upgrade the software version under the condition of uninterrupted service.
Specific reference: http:/ /tengine.taobao.org/book/

3.keepalived
Keepalived is a high-performance server high-availability or hot-standby solution. Keepalived can be used to prevent the occurrence of a single point of failure of the server. By cooperating with Nginx, the high availability of web front-end services can be achieved.
Keepalived is based on the VRRP protocol, and uses the VRRP protocol to achieve high availability (HA). The VRRP (Virtual Router Redundancy Protocol) protocol is a protocol used to implement router redundancy. The VRRP protocol virtualizes two or more router devices into one
device and provides virtual router IP (one or more) to the outside world. Inside the router group, If the router that actually owns the external IP is working normally, it is MASTER, or it is elected through an algorithm. MASTER implements various network functions for the virtual router IP, such as ARP request, ICMP, and data forwarding; other devices do not have This virtual IP, whose status is BACKUP
, does not perform external network functions except receiving VRRP status notification information from MASTER . When the host fails, BACKUP will take over the network function of the original MASTER. The VRRP protocol uses multicast data to transmit VRRP data. VRRP data uses a special virtual source MAC address to send data instead of the MAC address of its own network card. When VRRP is running, only the MASTER router regularly sends VRRP advertisement information, indicating that the MASTER is working normally and the
virtual router is working properly. IP (group), BACKUP only receives VRRP data and does not send data. If it does not receive the MASTER notification information within a certain period of time, each BACKUP will announce itself as a MASTER, send notification information, and re-elect the MASTER election state.

4. Comparison
(summary) for a detailed explanation of the advantages and disadvantages of Nginx/LVS/HAProxy load balancing software
: http://www.ha97.com/5646.html

=================================================
=================================================
=================================================
=================================================














Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326273029&siteId=291194637