Complete the code to set the load balancing method to least connections in NGINX.
upstream backend {
[1];
server backend1.example.com;
server backend2.example.com;
}The least_conn directive sets the load balancing method in an upstream block. Using least_conn; tells NGINX to use the least connections method.
Complete the code to enable least connections load balancing with a parameter to control the maximum number of connections.
upstream backend {
least_conn [1];
server backend1.example.com;
server backend2.example.com;
}max_fails with connection limits.weight which is for weighted load balancing.The max_conns parameter limits the maximum simultaneous connections to a server when using least connections load balancing.
Fix the error in the upstream block to correctly use least connections load balancing.
upstream backend {
[1];
server backend1.example.com;
server backend2.example.com;
}The directive balanc is a typo. The correct directive is least_conn to set the load balancing method.
Fill both blanks to configure an upstream block using least connections with max connections limit and a server with weight.
upstream backend {
least_conn [1];
server backend1.example.com [2];
}Use max_conns=10 to limit connections and weight=3 to assign server weight.
Fill all three blanks to create an upstream block with least connections, max connections limit, and two servers with weights.
upstream backend {
least_conn [1];
server backend1.example.com [2];
server backend2.example.com [3];
}The max_conns=15 limits connections, and the servers have weights 4 and 2 respectively.