worker_processes :linux
When set to 'auto', which is also the default behavior, Tengine will create the same number of worker processes as your CPUs.nginx
worker_cpu_affinity:
When set to 'auto', Tengine will automatically bind each worker process to a specific CPU. If the number of worker processes is larger than the number of your CPUs, then the rest of worker processes will be bond in descendant order. For example, if there are 8 CPUs in your system:服務器
worker_rlimit_nofile:網絡
每一個nginx進程打開文件描述符最大數目 配置要和系統的單進程打開文件數一致,linux 2.6內核下開啓文件打開數爲65535,worker_rlimit_nofile就相應應該填寫65535併發
use epoll高併發
Nginx使用了最新的epoll(Linux 2.6內核)和kqueue(freebsd)網絡I/O模ui
型,而Apache則使用的是傳統的select模型。
處理大量的鏈接的讀寫,Apache所採用的select網絡I/O模型很是低效。
在高併發服務器中,輪詢I/O是最耗時間的操做 目前Linux下可以承受高併發rest
訪問的Squid、Memcached都採用的是epoll網絡I/O模型。進程
worker_connections 65535;
每一個工做進程容許最大的同時鏈接數 (Maxclient = work_processes * worker_connections)ci
client_header_buffer_size 16klarge_client_header_buffers 4 32k客戶請求頭緩衝大小 nginx默認會用client_header_buffer_size這個buffer來讀取header值,若是header過大,它會使用large_client_header_buffers來讀取