NGINX
medium 28 minNGINX (say "engine x") is a web server, reverse proxy, load balancer and response cache.
Check yourself
One question at a time. Each answer explains why.
Question 1 of 12
What process model does NGINX use?
Why can it hold 10,000 connections cheaply?
About how much memory do 10,000 inactive keep-alive connections take?
What is the default balancing method?
Some requests take 5 ms and others 500 ms. Which method fits?
With `hash ... consistent`, a fourth equal server is added. About how many keys move?
100 requests arrive for one uncached page with the cache lock on. How many reach the backend?
Which cache status means an expired copy was served because the backend failed?
10,000 requests a second, one page, 1 second lifetime, lock on, one machine. Backend load?
Which algorithm is behind `limit_req`?
Five machines each have `rate=10r/s`. What can one client reach in the worst case?
Which command applies new configuration and lets requests finish?
Pick an answer to see why.
Not quite. The master manages; each worker runs an event loop over many connections.
Not quite. epoll or kqueue reports ready connections; waiting ones cost only a small record.
Not quite. The project states about 2.5 MB, roughly 250 bytes each.
Not quite. Requests go to servers in turn, according to weight.
Not quite. It avoids servers that are still busy with slow requests.
Not quite. The new server takes about 1 of 4 parts; the rest stay. A plain modulo would move most.
Not quite. One fetches, the others wait for it, up to the lock timeout of 5 seconds.
Not quite. STALE needs `proxy_cache_use_stale`. EXPIRED means it was fetched again.
Not quite. One refresh per key per second.
Not quite. The documentation calls it the leaky bucket method.
Not quite. Zones are not shared between machines.
Not quite. New workers start; old ones finish. `-t` only tests.
Flashcards
Say your answer, then reveal it.
Card 1 of 11
What does the master process do?
Reads configuration, binds ports, starts and replaces workers. It serves no requests.
Say your answer, then reveal it.
How many workers do you normally run?
One per CPU core: `worker_processes auto`. The built-in default is 1.
Say your answer, then reveal it.
Memory for 10,000 inactive keep-alive connections?
About 2.5 MB, says the project: about 250 bytes each.
Say your answer, then reveal it.
Default balancing method?
Weighted round robin.
Say your answer, then reveal it.
What does `proxy_cache_lock` do?
Lets one request fill a new cache entry while the others wait. Off by default.
Say your answer, then reveal it.
Which algorithm does `limit_req` use?
Leaky bucket, per key, per machine. Refusals are 503 unless you set 429.
Say your answer, then reveal it.
Default `client_max_body_size`?
1 MB. Larger uploads get 413.
Say your answer, then reveal it.
How do you reload safely?
`nginx -t`, then `nginx -s reload`. Old workers finish their requests.
Say your answer, then reveal it.
Why buffer responses?
The app is free at once; NGINX feeds the slow client.
Say your answer, then reveal it.
What is per worker and what per machine?
Idle upstream connections per worker. Cache and limit zones per machine.
Say your answer, then reveal it.
Active health checks in the open source version?
No, passive only: `max_fails` (1) and `fail_timeout` (10 s).
Say your answer, then reveal it.
These cards come back in Today, just before you would forget them.