0
0
Nginxdevops~10 mins

Least connections in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the load balancing method to least connections in NGINX.

Nginx
upstream backend {
    [1];
    server backend1.example.com;
    server backend2.example.com;
}
Drag options to blanks, or click blank then click option'
Aleast_conn
Bproxy_pass
Clisten
Dserver
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'proxy_pass' instead of 'least_conn' inside the upstream block.
Placing 'least_conn' outside the upstream block.
2fill in blank
medium

Complete the code to enable least connections load balancing with a parameter to control the maximum number of connections.

Nginx
upstream backend {
    least_conn [1];
    server backend1.example.com;
    server backend2.example.com;
}
Drag options to blanks, or click blank then click option'
Amax_conns=5
Bmax_fails=3
Cweight=2
Dfail_timeout=10s
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing max_fails with connection limits.
Using weight which is for weighted load balancing.
3fill in blank
hard

Fix the error in the upstream block to correctly use least connections load balancing.

Nginx
upstream backend {
    [1];
    server backend1.example.com;
    server backend2.example.com;
}
Drag options to blanks, or click blank then click option'
Aproxy_pass
Blisten
Cleast_conn
Dserver
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling the 'least_conn' directive.
Using directives not valid inside upstream blocks.
4fill in blank
hard

Fill both blanks to configure an upstream block using least connections with max connections limit and a server with weight.

Nginx
upstream backend {
    least_conn [1];
    server backend1.example.com [2];
}
Drag options to blanks, or click blank then click option'
Amax_conns=10
Bweight=3
Cmax_fails=2
Dfail_timeout=5s
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up max_fails and max_conns.
Placing weight outside the server directive.
5fill in blank
hard

Fill all three blanks to create an upstream block with least connections, max connections limit, and two servers with weights.

Nginx
upstream backend {
    least_conn [1];
    server backend1.example.com [2];
    server backend2.example.com [3];
}
Drag options to blanks, or click blank then click option'
Amax_conns=15
Bweight=4
Cweight=2
Dmax_fails=3
Attempts:
3 left
💡 Hint
Common Mistakes
Using max_fails instead of max_conns for connection limits.
Assigning weights outside server lines.