
- nginx는 multiplexing 과 event notifications 방식을 활용하면서 worker process라고 불리는 single-threaded processes들과 master process로 이루어진다.
- The master process 는 the privileged operations 를 담당하는데 예를 들어 conf 파일을 읽거나, port를 binding하고, 자식 프로세스를 만들어낸다.(The cache loader, The cache manager, The worker processes).
- The cache loader process 실행 되면서 디스크에 있는 메모리를 캐쉬로 가져온다.
- The cache manager process 디스크에 있는 캐쉬 데이터를 관리한다.
- The worker processes는 나머지 모든 작업을 다 한다. 네트워크 커넥션을 관리하고(요청 처리), disk i/o를 하면서 다른 서버와도 통신할 수 있다.
MasterProcess
- reading and validating configuration
- creating, binding and closing sockets
- starting, terminating and maintaining the configured number of worker processes
- reconfiguring without service interruption
- controlling non-stop binary upgrades (starting new binary and rolling back if necessary)
- re-opening log files
- compiling embedded Perl scripts
Worker
- Begin
ngx_worker_process_cycle().
- Process events with OS specific mechanisms (such as
epoll or kqueue).
- Accept events and dispatch the relevant actions.