0
0
Nginxdevops~20 mins

Least connections in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Least Connections Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Least Connections Load Balancing

What does the least connections method do in an NGINX load balancer?

AIt sends requests only to the server with the highest CPU usage.
BIt sends requests to servers in a fixed round-robin order regardless of load.
CIt sends requests randomly to any server in the pool.
DIt sends new requests to the server with the fewest active connections.
Attempts:
2 left
💡 Hint

Think about how to balance load by connection count.

Configuration
intermediate
2:00remaining
Configuring Least Connections in NGINX

Which NGINX configuration snippet correctly enables the least connections load balancing method?

Nginx
upstream backend {
    least_conn;
    server backend1.example.com;
    server backend2.example.com;
}
A
upstream backend {
    round_robin;
    server backend1.example.com;
    server backend2.example.com;
}
B
upstream backend {
    least_conn;
    server backend1.example.com;
    server backend2.example.com;
}
C
upstream backend {
    random;
    server backend1.example.com;
    server backend2.example.com;
}
D
upstream backend {
    ip_hash;
    server backend1.example.com;
    server backend2.example.com;
}
Attempts:
2 left
💡 Hint

Look for the directive that specifies least connections.

💻 Command Output
advanced
1:30remaining
Interpreting NGINX Upstream Status Output

Given this NGINX status output snippet showing active connections per backend server, which server will receive the next request if least_conn is enabled?

backend1.example.com - active connections: 5
backend2.example.com - active connections: 3
backend3.example.com - active connections: 7
Abackend3.example.com
Bbackend1.example.com
Cbackend2.example.com
DAll servers equally
Attempts:
2 left
💡 Hint

Which server has the fewest active connections?

Troubleshoot
advanced
2:00remaining
Troubleshooting Uneven Load Distribution

You configured NGINX with least_conn load balancing, but one backend server is still overloaded while others are idle. What is the most likely cause?

AThe overloaded server has long-lived connections that keep its active connection count high.
BNGINX is using round-robin instead of least connections.
CThe backend servers have different IP addresses configured incorrectly.
DThe DNS resolution for backend servers is failing.
Attempts:
2 left
💡 Hint

Think about how connection duration affects load balancing.

🔀 Workflow
expert
3:00remaining
Implementing Least Connections with Health Checks

You want to configure NGINX to use least_conn load balancing but also ensure that unhealthy backend servers are not used. Which configuration snippet correctly combines least connections with active health checks?

A
upstream backend {
    least_conn;
    server backend1.example.com max_fails=3 fail_timeout=30s;
    server backend2.example.com max_fails=3 fail_timeout=30s;
    health_check;
}
B
upstream backend {
    least_conn;
    server backend1.example.com;
    server backend2.example.com;
    check interval=3000 rise=2 fall=5 timeout=1000;
}
C
upstream backend {
    least_conn;
    server backend1.example.com;
    server backend2.example.com;
    health_check;
}
D
upstream backend {
    least_conn;
    server backend1.example.com max_fails=3 fail_timeout=30s;
    server backend2.example.com max_fails=3 fail_timeout=30s;
}
Attempts:
2 left
💡 Hint

Look for the combination of least_conn, server fail parameters, and health_check directive.