It sets the number of worker processes that nginx will start. Each worker handles client requests independently, improving performance by using multiple CPU cores.
Click to reveal answer
beginner
What does the worker_connections directive control in nginx?
It defines the maximum number of simultaneous connections each worker process can handle. This limits how many clients can be served at the same time per worker.
Click to reveal answer
intermediate
How do worker_processes and worker_connections work together?
The total maximum connections nginx can handle is roughly worker_processes × worker_connections. More workers and connections mean nginx can serve more clients simultaneously.
Click to reveal answer
intermediate
Why should worker_processes usually match the number of CPU cores?
Matching worker processes to CPU cores helps nginx use the server's hardware efficiently, avoiding too many processes competing for CPU time and improving request handling speed.
Click to reveal answer
beginner
What happens if worker_connections is set too low?
Nginx will limit the number of clients it can serve at once, causing some requests to wait or fail under high load, reducing server responsiveness.
Click to reveal answer
What does the worker_processes directive specify in nginx?
ANumber of worker processes to start
BMaximum connections per worker
CNumber of CPU cores to use
DTimeout for client connections
✗ Incorrect
worker_processes sets how many worker processes nginx will start to handle requests.
If you want nginx to handle more simultaneous clients, which directive should you increase?
Aworker_processes
Bclient_max_body_size
Cworker_connections
Dkeepalive_timeout
✗ Incorrect
worker_connections controls how many connections each worker can handle at once.
What is a good rule of thumb for setting worker_processes?
AMatch the number of CPU cores
BSet to 100
CSet to the number of clients
DSet to 1 always
✗ Incorrect
Setting worker_processes to the number of CPU cores helps use hardware efficiently.
How do you calculate the approximate max simultaneous connections nginx can handle?
Aworker_processes / worker_connections
Bworker_processes + worker_connections
Cworker_connections - worker_processes
Dworker_processes × worker_connections
✗ Incorrect
The total max connections is roughly worker_processes multiplied by worker_connections.
What might happen if worker_connections is too low during high traffic?
ANginx will crash
BRequests may queue or fail
CCPU usage will spike
DMemory usage will drop
✗ Incorrect
Low worker_connections limits simultaneous clients, causing delays or failures.
Explain how worker_processes and worker_connections affect nginx's ability to handle client requests.
Think about how many clients nginx can serve at once.
You got /4 concepts.
Describe why matching worker_processes to CPU cores is important in nginx configuration.
Consider how CPU cores and processes work together.
You got /4 concepts.
Practice
(1/5)
1. What does the worker_processes directive control in an nginx configuration?
easy
A. The timeout for client connections
B. The maximum size of client request body
C. The number of server blocks defined
D. The number of worker processes handling client requests
Solution
Step 1: Understand the role of worker_processes
This directive sets how many worker processes nginx will start to handle incoming requests.
Step 2: Compare with other options
Other options relate to different settings like request size, server blocks, or timeouts, not worker count.
Final Answer:
The number of worker processes handling client requests -> Option D
Quick Check:
worker_processes = number of workers [OK]
Hint: worker_processes = how many workers run [OK]
Common Mistakes:
Confusing worker_processes with worker_connections
Thinking it controls timeout or request size
Mixing it with server block count
2. Which of the following is the correct syntax to set worker connections to 1024 in nginx?
easy
A. worker_connections = 1024
B. worker_connections 1024;
C. worker_connections: 1024
D. worker_connections(1024);
Solution
Step 1: Recall nginx directive syntax
nginx directives use the format: directive_name value; without equals or parentheses.
Step 2: Identify correct syntax
worker_connections 1024; matches this format exactly with a semicolon ending.
Final Answer:
worker_connections 1024; -> Option B
Quick Check:
nginx directives end with semicolon [OK]
Hint: nginx directives end with semicolon, no equals [OK]
Common Mistakes:
Using equals sign (=) in directive
Using colon (:) instead of space
Adding parentheses around values
3. Given the following nginx config snippet:
worker_processes 2;
worker_connections 512;
What is the maximum number of simultaneous connections nginx can handle?
medium
A. 512
B. 256
C. 1024
D. 2
Solution
Step 1: Understand the meaning of directives
worker_processes = 2 means 2 workers; worker_connections = 512 means each worker can handle 512 connections.