Reprinted from: http://onlyzq.blog.51cto.com/1228/557848
1. Polling (default)Each request is assigned to a different backend server one by one in chronological order. If the backend server goes down , can be automatically eliminated.
2. Weight
specifies the polling probability. Weight is proportional to the access ratio and is used when the performance of the back-end server is uneven.
For example:
upstream bakend {
server 192.168.159.10 weight=10;
server 192.168.159.11 weight=10;
}
3. ip_hash
Each request is allocated according to the hash result of the accessed ip, so that each request Each visitor has fixed access to a back-end server, which can solve the session problem.
For example: upstream resinserver{
ip_hash;
server 192.168.159.10:8080;
server 192.168.159.11:8080;
}
4. fair (third party)
Allocate requests according to the response time of the backend server , priority is given to those with short response times. upstream resinserver{
server server1;
server server2;
fair;
}
5, url_hash (third party) Distribute requests according to the hash result of the accessed URL, so that each URL is directed to the same backend Server, it is more effective when the back-end server is cache. Example: Add a hash statement to upstream. Other parameters such as weight cannot be written in the server statement. hash_method is the hash algorithm used
upstream resinserver{
server squid1:3128;
server squid2:3128;
hash $ Request_uri;
hash_method CRC32;
} Tips: Upstream ResinServer {#Define the IP and device status of the load balancing device ip_hash; 7.0.0.1:8080 weight = 2;server 127.0.0.1:6801;
server 127.0.0.1:6802 backup;
}
Add
proxy_pass http://resinserver/;status of each device in the server that needs to use load balancing Set to: 1.down means that the previous server will not participate in the load temporarily 2.weight The default is 1. The larger the weight, the greater the weight of the load. 3.max_fails: The number of allowed request failures defaults to 1. When the maximum number is exceeded, the error defined by the proxy_next_upstream module is returned.
4.fail_timeout: The pause time after max_fails failures.
5.backup: When all other non-backup machines are down or busy, request the backup machine. So this machine will have the least pressure.
nginx supports setting up multiple groups of load balancing at the same time for use by unused servers.
client_body_in_file_only Set to On, the data posted by the client can be recorded into a file for debugging client_body_temp_path Set the directory of the recording file to set up to 3 levels of directories location matches the URL. You can redirect or create a new proxy Load balancing
The above introduces the distribution method of Nginx upstream (transfer), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.