Nginx

1. Abstract

Event Driven architecture enabling servicing thousands of concurrent requests

2. Basics

2.1. Design

  • Has one master and several worker processes (recommended as the number of CPU cores available).
  • the master managers the workers and is responsible for reading the configuration.
  • the workers are what do the actual work and serve requests.

2.2. Configuration

  • the configuration file defines the state of nginx
    • /usr/local/nginx/conf/nginx.conf
    • /etc/nginx/nginx.conf
    • /usr/local/etc/nginx/nginx.conf
  • the config application is composed of:
    • syntax validation
    • accept master specific configs
    • create new workers and notify older workers
      • older workers stop accepting new requests and serve the ones that are active before a graceful death

2.3. Graceful shutdown

  • graceful in here: serves old requests and stops accepting new ones before the workers exit
  • send a quit signal to the master process
    • kill -s QUIT <nginx-master-pid>

2.4. State

  • for all current relevant workers:
    • ps -aux | grep nginx should do it
    • individual investigation of pids as needed via the file system's internals

2.5. Interface

  • coms by signalling the master process with signals:
    • stop, quit, reload, reopen
    • nginx -s stop , for instance
Tags::web:cs: