2 ms·
"Nginx has a single master thread that does async select on the main socket. Once it receives a connection it hands off to worker threads" Nginx has a master p
by zzzcpan 9y ago
"Nginx has a single master thread that does async select on the main socket. Once it receives a connection it hands off to worker threads"
Nginx has a master process and worker processes. Master process doesn't do anything, but manage worker processes in case they die or need to be restarted on configuration change. A worker process runs a single event loop that accepts connections. It doesn't hand off them anywhere, but just schedules connection handlers to be run in the same event loop. Worker processes don't share memory (almost, there are some sysv shared memory segments for a few things, but this is irrelevant). Thread pools in nginx were added only relatively recently to do blocking file I/O on linux, which is kind of slow otherwise in some scenarios.