1, the polling (default)
Each request individually assigned to a different time order back-end server, if the back-end server is down, can be automatically removed.
2, weight
polling a probability proportional to weight ratio and access, for the case where unevenness backend server performance.
For example:
copy the code code is as follows:
upstream backend {
server 192.168.0.14 weight=10;
server 192.168.0.15 weight=10;
}
3, ip_hash
each request assigned by hash result Access ip so that each visitor to access a fixed back-end server, can solve the problem of session.
For example:
copy the code code is as follows:
upstream backend {
ip_hash;
server 192.168.0.14:88;
server 192.168.0.15:80;
}
4, fair (third party)
by the response time of the allocation request to the backend server, a short response time priority allocation.
Copy the code code is as follows:
upstream backend {
server server1.linuxany.com;
server server2.linuxany.com;
fair;
}
5, url_hash (third party)
Press access url hash result to the allocation request, each url directed to the same back-end server, the back end server is effective when the cache.
Example: added upstream the hash statement, server statement can not be written other parameters like weight, hash_method hash algorithm is used
to copy the code follows the code:
{backend upstream
Server squid1: 3128;
Server squid2: 3128;
the hash $ REQUEST_URI;
hash_method CRC32;
}
# define the load balancing device and the device state Ip
upstream backend {
ip_hash;
Server Down 127.0.0.1:9090;
Server 127.0.0.1:8080 2 = weight;
Server 127.0.0.1:6060;
Server 127.0.0.1:7070 Backup;
}
Increase in server load balancing is required in
proxy_pass HTTP: // bakend /;
The status of each device is set to:
1.down a front single server is temporarily not participate in load
2.weight default 1.weight greater, the greater the weight load of weight.
3.max_fails: the number of permitted requests failed 1. When default exceeds the maximum number, returns proxy_next_upstream module defined error
4.fail_timeout: max_fails failed after pause time.
5.backup: all other backup machine down or non-busy times, requests backup machine. So this machine will be the lightest pressure.
nginx supports simultaneous load balancing multiple sets of settings, not used to the server to use.
client_body_in_file_only set to On can speak client post over the data to a file used for debug
directory client_body_temp_path set the log file directory can be set up to layer 3
location on URL matching can be redirected or a new proxy load balancing