I started nginx with just a single worker.
ps --forest -fC nginx
UID PID PPID C STIME TTY TIME CMD
root 3615889 10118 0 14:18 ? 00:00:00 nginx: master process nginx
nginx 3615890 3615889 0 14:18 ? 00:00:00 \_ nginx: worker process
both processes listen on ports 80.
- pid=3615889 is master
- pid=3615890 is worker
so when a request comes from the internet - who will process it?
How the flow works from OSI layer standpoint? Am I wrong to assume that all requests will go to a master and then routed to the worker or workers can process requests independently?
I'm confused by both processes listening to the same socket (device #2151156)
sudo ss -ltnp | grep nginx
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=3615890,fd=8),("nginx",pid=3615889,fd=8))
LISTEN 0 511 [::]:80 [::]:* users:(("nginx",pid=3615890,fd=9),("nginx",pid=3615889,fd=9))
sudo lsof -i TCP:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 3615889 root 8u IPv4 2151156 0t0 TCP *:http (LISTEN)
nginx 3615889 root 9u IPv6 2151157 0t0 TCP *:http (LISTEN)
nginx 3615890 nginx 8u IPv4 2151156 0t0 TCP *:http (LISTEN)
nginx 3615890 nginx 9u IPv6 2151157 0t0 TCP *:http (LISTEN)