nginx upstream currently supports 4 ways of allocation 1, polling (default)
Each request is assigned one by one in chronological order Different backend servers can be automatically culled if the backend server is down.
2, weight
Specify the polling probability, which is proportional to the access ratio and is used for the performance of the backend server.
Example:
upstream bakend {
server 192.168.0.14 weight=10;
server 192.168.0.15 weight=10;
}
2, ip_hash
Each request is assigned by the hash result of the access ip, so that each visitor can access a backend server to solve the session problem. .
Example:
upstream bakend {
ip_hash;
server 192.168.0.14:88;
server 192.168.0.15:80 ;
}
3, fair (third party)
Assigning requests by response time of the backend server, short response priority allocation .
upstream backend {
server server1;
server server2;
fair;
}
4, url_hash (third party)
Assign the request by the hash result of the access url, so that each url is directed to the same backend server, the backend server is cached It is more effective.
Example: Adding a hash statement in the upstream, the server statement can not write weight and other parameters, hash_method is the hash algorithm used
upstream backend {
server squid1:3128;
server squid2:3128;
hash $request_uri;
hash_method crc32;
}
tips:
upstream bakend{#Define Ip and device status of load balancing devices
ip_hash;< Br>
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;
}
Adding
proxy_pass http://bakend/;
to servers that need to use load balancing >
The status of each device is set to:
1.down means that the server before the single is not involved in the load temporarily
2.weight The default is 1.weight is bigger, the weight of the load It is bigger.
3.max_fails : The number of times a request is allowed to fail defaults to 1. When the maximum number of times is exceeded, the error defined by the proxy_next_upstream module is returned
4.fail_timeout: The time after the failure of max_fails times.
5.backup: When all other non-backup machines are down or busy, request a backup machine. So this machine will be the lightest.
nginx supports multiple sets of load balancing at the same time, which is used for unused servers.
client_body_in_file_only Set to On. You can talk about the data from the client post to the file for debugging.
client_body_temp_path Set the directory of the log file to up to 3 levels. Br>
location Match URLs. You can redirect or perform new proxy load balancing
With the advantage of strong stability, embedded DVR is increasingly accepted by the security indust
date command The function of the date command is to display and set the system date and time. The ge
A.Linux files can be divided into four types: ordinary files, directory files, link files, and devi
One of the best things about Linux is that you can go deep into the operating system to explore how
Linux installation ImageMagick and JMagick complete process and configuration tutorial
XXX is not in the sudoers file. This incident will be report
How to enable dhcp relay to assign IP
How to read multiple files at the same time in the shell
The difference between Linux and Windows
Linux system garbled problem solution
Redis-benchmark performance test tutorial
Linux common problems and errors Chinese analysis (system articles)
Linux shell string operation (length, find, replace) detailed
Linux system /etc/fstab loss, mount LVM repair
Strange system: netizen homemade web version of Windows 93
Method for letting DOS programs run under xp system
How to set win10 system time to display 24 hours?
Real-time synchronization of Linux and Windows system files
What if the win10 program does not respond? Win10 program no response solution
What should I do if win8 msvcr100.dll is missing?
Win7 browse the web page blue screen error 1000008E solution
How Win8 uses the links of the People app to integrate the same contacts