1. 程式人生 > >優化 Nginx 處理事件模型

優化 Nginx 處理事件模型

標準 root 高效 nginx pre conf icop con div

Nginx 的連接處理機制在不同的操作系統會采用不同的 I/O 模型,要根據不同的系統選擇不同的事件處理模型,可供選擇的事件處理模型有:kqueue 、rtsig 、epoll 、/dev/poll 、select 、poll ,其中 select 和 epoll 都是標準的工作模型,kqueue 和 epoll 是高效的工作模型,不同的是 epoll 用在 Linux 平臺上,而 kqueue 用在 BSD 系統中。

(1) 在 Linux 下,Nginx 使用 epoll 的 I/O 多路復用模型
(2) 在 Freebsd 下,Nginx 使用 kqueue 的 I/O 多路復用模型
(3) 在 Solaris 下,Nginx 使用 /dev/poll 方式的 I/O 多路復用模型

(4) 在 Windows 下,Nginx 使用 icop 的 I/O 多路復用模型

[[email protected] ~]# cat /usr/local/nginx/conf/nginx.conf
...... events {
use epoll;
}
......

優化 Nginx 處理事件模型