nginx load balancing simple example

nginx server allocation strategy

Polling (default)

Each individual distribution request to a different chronological scourge server, if the back-end server is down, automatically conflict

2.weight (weight)

Representative weights more weight, as a default, the higher the weight assigned to the requested client

3.ip hash

Each access request assigned by ip hash results, so that each access a back-end server before fixing

4.fair (third party)

Class response time distribution according to the backend server a request, response time priority allocation

First, what to do?

 

 

 Second, what to do?

1. Required environment

The virtual machine will need to install jdk + tomcat (two) + nginx

2. Configure nginx environment

Enter /usr/local/nginx/conf/nginx.conf

2.1. Polling Policy

2.1.1. Configuration

upstream representation is a list of servers you want to load balancing

proxy_pass jump is the path you specified

2.1.2. Test

 

refresh

 

8080 and 8081 servers are distributed equally

2.2. Weight Strategy

2.2.1 Configuration

 

 

 Chant access number 8081 server is twice the 8080 server

2.3. ip hash

2.3.1 Configuration

 

 2.4.fair

2.4.1. Configuration

 

Guess you like

Origin www.cnblogs.com/BeenTogether/p/11617106.html