Nginx upstream currently supports 5 modes of distribution

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

1, Polling (default)

Each request according to the time sequence are assigned to different backend server, if the server down off, can automatically remove.

2, weight
Specify the polling probability, weight and access rate is proportional to the back-end server performance, the situation of uneven.
For example:

The following code fragment:
upstream bakend {  
  server 192.168.0.14 weight=10;  
  server 192.168.0.15 weight=10;  
}

 
3, ip_hash
Each request to access the IP hash results distribution, so that each visitor fixed access a back-end server, session can solve the problem of.
For example:
 
The following code fragment:
upstream bakend {  
  ip_hash;  
  server 192.168.0.14:88;  
  server 192.168.0.15:80;  
}

 
4, Fair (third party)
According to the response time of the back-end server to assign priority allocation request, response time is short.
 
The following code fragment:
upstream backend {  
  server server1;  
  server server2;  
  fair;  
}
5, Url_hash (third party)

According to access URL hash results to the allocation request, so that each URL directed to the same server, back-end server to cache more effectively.

Example: add hash statements in upstream, weight and other parameters can not write a server statement, hash_method is the use of the hash algorithm

The following code fragment:
 upstream backend {  
  server squid1:3128;  
  server squid2:3128;  
  hash $request_uri;  
  hash_method crc32;  
}  
   
upstream bakend{#Definition of load Ip and equipment state making balance equipment
  ip_hash;  
  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; 
 
 



The need to use the increased load balance in server

The following code fragment:
proxy_pass ;

 
Each device status is set to:
1.down represents a single server before temporarily not participating in the load
2.weight default is 1.weight larger load, the more weight.
3.max_fails : Number of allowed requests failed 1 by default when more than the maximum number, return to the proxy_next_upstream module defined error
4.fail_timeout:max_fails failed, pause time.
5.backup: All other non backup machine down or busy time, request the backup machine. So this machine will be the lightest pressure.

Nginx support and set the load balanced multi group, used to give not to use server.

Client_body_in_file_only is set to On you can say client post over logging data to file for debug
Client_body_temp_path setup log file directory can be set up to 3 layer directory

Location on URL is matched. Can redirect or new proxy load balancing

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Don at January 13, 2014 - 6:24 AM