Thursday 1 May 2014

Nginx Common Section Configuration Considerations

This blog is about the Nginx common section configuration.



Main module

error_log

error_log is used for error logging function. syntax is

error_log file | stderr [ debug | info | notice | warn | error | crit | alert | emerg ]

if we compile the nginx with "--with-debug", we can enable debug function as below:
error_log LOGFILE [debug_core | debug_alloc | debug_mutex | debug_event | debug_http | debug_imap];
the way to disable the error_log :

error_log /dev/null crit;
 

timer_resolution

by default, everytime when return from kevent(), epoll, /dev/poll, select() or poll() , nginx will call gettimeofday(), it may not needed, we can specify the internal by
timer_resolution interval

for example
timer_resolution  100ms;

 

worker_cpu_affinity

this configuration can use sched_setaffinity() to combine the thread to dedicated CPU.

worker_cpu_affinity cpumask ...

for example
worker_processes     4;
worker_cpu_affinity 0001 0010 0100 1000;

 

worker_priority

This defination setup the nice value for the worker processes.
worker_priority number

 

worker_processes

this configuration defines the working processes numbers, usually it should match the CPU numbers and also the affinity

 

worker_rlimit_nofile

this configuration defines the maxim file descriptions each working procedure can open.
worker_rlimit_nofile number

 

Events module

worker_connections

it defines the max connection each worker process can handle
max clients = worker_processes * worker_connections 
under the reverse proxy situation: 
max clients = worker_processes * worker_connections/4

 

use

you can choose the IO mode for Nginx. By default, it will be epoll in Linux System.
use [ kqueue | rtsig | epoll | /dev/poll | select | poll | eventport ]

No comments:

Post a Comment