1.1 What is load balancing
Based on the existing network structure, load Balancing provides a cheap and effective way to expand network equipment and server bandwidth, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability.
Load balancing, the English name is load Balance, which means that it is distributed across multiple operating units for execution, such as Web servers, FTP servers, enterprise critical application servers, and other mission-critical servers, to work together to accomplish tasks.
1.2 Requirements
Nginx as a Load balancer server, the user requests to reach Nginx first, and then by Nginx according to the load configuration to forward the request to the Tomcat server.
Nginx Load Balancer Server: 192.168.25.141
TOMCAT1 Server: 192.168.25.141:8080
TOMCAT2 Server: 192.168.25.141:8081
1.3 Configuring Nginx Load Balancing
This configuration is built on the basis of Nginx reverse proxy.
Nginx Reverse Proxy: http://www.cnblogs.com/append/p/5740472.html
1.4 Configuring load-balancing weights
Node Description: Add in the HTTP node: #定义负载均衡设备的 IP and Device status Upstream MyServer { Server 127.0.0.1:9090 down; Server 127.0.0.1:8080 weight=2; Server 127.0.0.1:6060; Server 127.0.0.1:7070 backup; } Add under the server node that needs to use the load Proxy_pass Http://myServer; Upstream the status of each device: Down indicates that the server is temporarily not participating in the load Weight by default, the larger the 1.weight, the greater the load weight. Max_fails: The number of times that a request failed is allowed defaults to 1. Returns the error defined by the Proxy_next_upstream module when the maximum number of times is exceeded Fail_timeout:max_fails the time of the pause after the failure. Backup: When all other non-backup machines are down or busy, request the backup machine. So the pressure on this machine is the lightest. |
High availability of 1.5 nginx
Solving a highly available scenario is adding redundancy.
Configuring Nginx Load Balancing