Configuring Nginx Load Balancing

Source: Internet
Author: User
Tags nginx reverse proxy nginx load balancing

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

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.