#master-worker
Posts
-
Digging into nginx's Source 2: The Big Picture — Master and Workers, Modules, the Cycle and Config Contexts
The map for the whole series, written for intermediate programmers opening the nginx source for the first time. Where the single master and the workers each spend their time waiting, how every feature plugs in as one ngx_module_t and why module types are the ASCII letters "CORE" and "HTTP", what ngx_cycle_t and conf_ctx hold for a running nginx, how the main, events, http, server and location contexts of nginx.conf are checked with bit flags, and how one worker's event loop juggles hundreds of connections — all checked against the real source with ps and gdb examples.
-
Digging into nginx's Source 6: Master and Workers — Processes, Signals and Zero-Downtime Reload
We follow src/os/unix/ngx_process_cycle.c to see how one nginx -s reload wakes the master's sigsuspend() loop, starts new workers with the new config, and lets the old workers finish what they were doing before they leave. Why the signal handler only sets a flag, the socketpair channel between master and workers, the respawn, just_spawn and exiting bits in the ngx_processes[] table, how a worker killed with kill -9 comes back, and the USR2 binary upgrade — all checked with strace, debug logs and ps.