Using Nginx+tomcat load Balancing

Source: Internet
Author: User
Tags nginx server nginx load balancing

Callout: This article belongs to the original content of Ant class, other website reprint must mark source and Ant class. Www.itmayiedu.com

1.1 What is load balancing

web

650) this.width=650; "Src=" http://www.itmayiedu.com/images/upload/ueditor/image/20170104/1483519667003048949. PNG "style=" margin:0px Auto;padding:0px;border:0px;vertical-align:baseline;background:transparent;height:auto; " alt= "1483519667003048949.png"/>

1.2 Demand

Nginx as a load balancer server, the user requests to arrive firstNginx, and then byNginxforwarding requests to a load configurationTomcatserver.

In the real world, Nginx and Tomcat servers are separate.

1.3 Add a local domain name to the host file

127.0.0.1 www.itmayiedu.com

1.4 Configuring Nginx Load Balancing

650) this.width=650; "Src=" http://www.itmayiedu.com/images/upload/ueditor/image/20170104/1483519667050046703.png "Style=" margin:0px auto;padding:0px;border:0px;vertical-align:baseline;background:transparent;height:auto; "alt= "1483519667050046703.png"/>

1.5 Configure weight for load Balancing

650) this.width=650; "Src=" http://www.itmayiedu.com/images/upload/ueditor/image/20170104/1483519667205089000.png "Style=" margin:0px auto;padding:0px;border:0px;vertical-align:baseline;background:transparent;height:auto; "alt= "1483519667205089000.png"/>

Using weight to configure load balancing, the weight defaults to 1, and the higher the weight, the more requests are processed.

node Description:
added 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;&NBSP
}

Add

Proxy_pass http://myServer under the server node that needs to use the payload;

Upstream the status of each device:

down indicates that the server before the single is temporarily not participating in load  
Weight The larger the default is 1.weight, the greater the load weight.  
Max_fails: The number of times a request fails is defaulted to 1. Returns the error   defined by the Proxy_next_upstream module when the maximum number of times is exceeded;
Fail_timeout:max_fails Times failed, The time of the pause.  
Backup: When all other non-backup machines are down or busy, request the backup machine. So the pressure on this machine is the lightest.

1.6 

650) this.width=650; "Src=" http://www.itmayiedu.com/images/upload/ueditor/image/20170104/1483519667237005015.png "Style=" margin:0px auto;padding:0px;border:0px;vertical-align:baseline;background:transparent;height:auto; "alt= "1483519667237005015.png"/>

650) this.width=650; "Src=" http://www.itmayiedu.com/images/upload/ueditor/image/20170104/1483519667454054911.png "Style=" margin:0px auto;padding:0px;border:0px;vertical-align:baseline;background:transparent;height:auto; "alt= "1483519667454054911.png"/>

Address bad input: Www.itmayiedu.com through the nginx server load balancer, randomly forwarded to 8080 server or 8082 server.


This article is from "Ant classroom" blog, please make sure to keep this source http://itmayiedu.blog.51cto.com/6234756/1889008

Using Nginx+tomcat 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.