First, distribution mode
1. Polling method (default)
Upstream Realserver {server 192.168.1.1; Server 192.168.1.2;}
Each request is assigned in chronological order to a different server on the backend, and if a server goes down, the server is automatically rejected.
2.weight weights
Upstream Realserver {server 192.168.1.1 weight=5; Server 192.168.1.2 weight=8;}
depending on the performance of the backend server, the probability of being accessed is set, the higher the number, the greater the chance.
3.ip_hash
Upstream Realserver {ip_hash; Server 192.168.1.1; Server 192.168.1.2;}
This enables a fixed IP to access a backend server, which can effectively solve the user session problem.
4.fair (third Party)
Upstream Realserver {server 192.168.1.1; Server 192.168.1.2; Fair;}
Allocation of requests According to the response speed of the backend server, with short response times prioritized
5.url_hash (third Party)
Upstream Realserver {server 192.168.1.1; Server 192.168.1.2; Hash $request _uri; Hash_method CRC32;}
According to the hash result of the URL to allocate the request, so that each URL address request to the same back-end server, the back-end server for the cache server is more effective. Parameters such as weight cannot be used at this time
Second, the equipment status
Down : Indicates that the device is in a deactivated state
Backup: Indicates that the device is a standby device and is assigned to the request only if all devices except him are down or busy.
Weight: Represents a weight, the greater the value, the greater the chance of being requested.
Max_fails and fail_timeout are generally used for association, Max_fails sets the number of times a request fails to be allowed, by default 1. Fail_timeout sets the number of times the request failed n times after which the service is no longer requested, the default is 10s.
Nginx's upstream centralized distribution mode