0
0
Nginxdevops~20 mins

Connection pooling to upstream in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Connection Pooling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Nginx Upstream Connection Pooling Behavior

Given the following nginx upstream configuration, what is the maximum number of idle keepalive connections nginx will maintain to the upstream servers?

Nginx
upstream backend {
    server backend1.example.com max_fails=3 fail_timeout=30s;
    server backend2.example.com max_fails=3 fail_timeout=30s;
    keepalive 10;
}

server {
    location / {
        proxy_pass http://backend;
    }
}
A10 connections per each upstream server
B10 connections total shared across all upstream servers
CUnlimited connections, keepalive does not limit connections
D3 connections total due to max_fails setting
Attempts:
2 left
💡 Hint

Think about what the keepalive directive controls in the upstream block.

Configuration
intermediate
2:00remaining
Configuring Upstream Keepalive Connections

Which of the following nginx upstream configurations correctly enables connection pooling with 20 keepalive connections per upstream server?

A
upstream backend {
    server backend1.example.com;
    server backend2.example.com;
    keepalive_connections 20;
}
B
upstream backend {
    server backend1.example.com keepalive=20;
    server backend2.example.com keepalive=20;
}
C
upstream backend {
    server backend1.example.com;
    server backend2.example.com;
    keepalive 20;
}
D
upstream backend {
    server backend1.example.com max_fails=20;
    server backend2.example.com max_fails=20;
}
Attempts:
2 left
💡 Hint

Remember the exact syntax for the keepalive directive inside the upstream block.

Troubleshoot
advanced
2:00remaining
Diagnosing Connection Pooling Issues

An nginx server is configured with an upstream block using keepalive 15;. However, monitoring shows nginx opens many more than 15 connections to the upstream servers under load. What is the most likely cause?

AThe <code>max_fails</code> directive is set too low causing connections to reopen frequently
BThe <code>keepalive</code> directive only limits idle connections, active connections can exceed this number
CThe <code>keepalive</code> directive must be set inside the server block, not upstream
DNginx does not support connection pooling with HTTP upstreams
Attempts:
2 left
💡 Hint

Consider the difference between idle and active connections in nginx's connection pooling.

🔀 Workflow
advanced
2:00remaining
Implementing Connection Pooling for Upstream Servers

You want to configure nginx to reuse TCP connections to upstream servers to improve performance. Which sequence of steps is correct?

A2, 1, 3, 4
B1, 2, 4, 3
C1, 3, 2, 4
D1, 2, 3, 4
Attempts:
2 left
💡 Hint

Think about the order of defining upstream, enabling keepalive, and configuring proxy headers.

Best Practice
expert
2:00remaining
Best Practice for Connection Pooling with Multiple Upstream Servers

When configuring connection pooling with multiple upstream servers in nginx, which practice helps ensure efficient connection reuse and load balancing?

AUse a single upstream block with multiple servers and a keepalive directive to share pooled connections across all servers
BCreate separate upstream blocks for each server with individual keepalive settings to isolate connections
CSet max_fails to 0 to prevent connection failures from closing pooled connections
DDisable keepalive and rely on nginx to open new connections for each request to balance load evenly
Attempts:
2 left
💡 Hint

Consider how nginx manages pooled connections and load balancing across servers.