Nginx系列教程:事件模块

设置Nginx处理连接请求

指令

accept_mutex

Syntax: accept_mutex [ on | off ]

Default: on

nginx 使用连接互斥锁进行顺序的accept()系统调用.

accept_mutex_delay

Syntax: accept_mutex_delay Nms;

Default: 500ms

如果一个进程没有互斥锁,它将延迟至少多长时间。默认情况下,延迟是500ms 。

debug_connection

Syntax: debug_connection [ip | CIDR]

Default: none

Since 0.3.54 this option support CIDR address format

This option gives you the ability to write debug log only for the clients of this IP/NET.

Several different directives are possible.

Example:

error_log /var/log/nginx/errors;">events { debug_connection
192.168.1.1;}

devpoll_changes

devpoll_events

kqueue_changes

kqueue_events

epoll_events

Syntax: devpoll_changes

Default:

These directives specify how many events may be passed to/from kernel, using appropriate method.

The default devpoll values are 32, the rest are 512.

multi_accept

Syntax: multi_accept [ on | off ]

Default: off

multi_accept tries to accept() as many connections as possible after nginx gets notification about a new connection.

rtsig_signo

Syntax: rtsig_signo

Default:

nginx uses two signals when the rtsig method is used. The directive specified the first signal number. The second is plus 1.

By default rtsig_signo is SIGRTMIN+10 (40).

rtsig_overflow_events

rtsig_overflow_test

rtsig_overflow_threshold

Syntax: rtsig_overflow_*

Default:

These directives specifies how to handle rtsig queue overflows. When overflow occurred nginx flushes rtsig queue, then it handles events switching between poll() and rtsig. poll() handles consecutively all unhandled events, while rtsig periodicaly drains queue to prevent a new overflow. When overflow is handled completely, nginx switches to rtsig method again.

The rtsig_overflow_events specifies the number of events to be passed via poll(). The default is 16.

The rtsig_overflow_test specifies after which number of events handled by poll() nginx will drains rtsig queue. The default is 32.

The rtsig_overflow_threshold works in Linux 2.4.x only. Before to drain rtsig queue nginx looks in a kernel how the queue is filled up

The default is 1/10. "rtsig_overflow_threshold 3" means 1/3.

use

Syntax: use [ kqueue | rtsig | epoll | /dev/poll | select | poll | eventport ]

Default:

如果在./configure的时候指定了不止一种事件模型,那么可以设置其中一个,以便告诉nginx使用哪种事件模型。默认情况下nginx会在./configure时找出最适合系统的事件模型。

你可以在 这里 查看可用的事件模型以及如何在./configure时激活

worker_connections

Syntax: worker_connections number

Default:

通过worker_connections和worker_proceses可以计算出maxclients:

max_clients = worker_processes * worker_connections

作为反向代理,max_clients为:

max_clients = worker_processes * worker_connections/4

Since a browser opens 2 connections by default to a server and nginx uses the fds (file descriptors) from the same pool to connect to the upstream backend

时间: 2024-09-20 06:13:22

Nginx系列教程:事件模块的相关文章

Nginx系列教程:nginx_substitutions_filter模块

nginx_substitutions_filter 请注意:此模块不是Nginx源的分布,可点击此链接找到安装说明, http://wiki.nginx.org/NginxHttpSubsModule#Installation . 概述 nginx_substitutions_filter 是一个过滤器模块,它可以在响应主体上运行正则表达式和固定字符串替换.该 模块不同于Nginx的本地替代模块.它能够扫描输出链缓冲区和匹配逐行字符串,类似于http://www.aliyun.com/zixu

Nginx系列教程:HTTP Upstream Request Hash模块

ngx_http_upstream_hash_module 本模块由第三方提供,不包含在 Nginx 的源码发布版中. upstream_hash该模块提供了简单的上游负载分配,通过散列一个可配置的变量(例如,请求URI,传入的HTTP标头或一些组合).用法示例如下: upstream backend {: server server1;: server server2;: hash $request_uri;} 在这里,nginx将通过散列请求的URI($ REQUEST_URI)选择Serv

Nginx系列教程:HTTP OwnerMatch模块

我编写了一个 Nginx 模块 HTTP OwnerMatch 解决了 Nginx http://www.aliyun.com/zixun/aggregation/14840.html">虚拟主机间可通过链接型文件(硬链接和符号链接)跨站访问的问题.通过这个模块可以指定每个虚拟主机的每个 Location 可以或不可以访问的哪些用户的文件. 配置文件实例 location / { root html; index index.html index.htm; omallow heiher;

Nginx系列教程:Http Access Key模块

此模块没有被包含在Nginx官方安装包中. 这个模块可以阻止所有URL中未包含合法访问令牌的访问(防盗链).访问令牌可以由访问者IP或者其它服务器变量生成,所以可以很好地控制客户端的下载行为. 配置实例: location /download {&http://www.aliyun.com/zixun/aggregation/37954.html">nbsp; accesskey             on;  accesskey_hashmethod  md5;  access

Nginx系列教程:ngx_cache_purge模块

ngx_cache_purge 本模块由第三方提供,不包含在 Nginx 的源码发布版中. 概述 ngx_cache_purge是nginx模块,用于从FastCGI.proxy.SCGI 和uWSGI5603.html">缓存中增加内容清除功能. 安装 下载模块源码:ngx_cache_purge-1.2(更新记录)(SHA1: d9468cf42432e81ea3a110ec63aae2eb273f5516) 其他版本 解压,然后编译: ./configuremake &&am

Nginx系列教程:HTTP DAV模块

这个模块可以为Http webDAV 增加 PUT, DELETE, MKCOL, COPY 和 MOVE 等方法. 这个模块在默认编译的情况下不是被包含的,你需要在编译时指定如下参数: ./ configure --with-http_dav_module 配置范例: location / { root /data/www; client_body_temp_path /data/client_temp; dav_methods PUT DELETE MKCOL COPY MOVE; crea

Nginx系列教程:HTTP Real IP模块

HttpRealIpModule模块简介 这个模块允许从请求Headers里更改客户端的IP地址值(例如 实时的转发). 它是有用的,如果nginx后面有多层http://www.aliyun.com/zixun/aggregation/13996.html">负载均衡/代理,nginx转发请求时将会添加添加客户端的IP头. 这个模块是不是建立在默认情况下,需要这样启用它 --with-http_realip_module 用户评论:"你将建立一个值得信赖的代理列表(见下文)和客

Nginx系列教程:HTTP Stub Status模块

ngx_http_stub_status_module 这个模块能够获取Nginx自上次启动以来的工作状态 此模块非核心模块,需要在编译的时候手动添加编译参数 --with-http_stub_status_module __配置说明__ location /nginx_status {: # copied from http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/: stub_status on;: access

Nginx系列教程:HTTP模块

控制Nginx HTTP 进程的核心属性. 指令 alias 语法: alias file-path|directory-path; 默认值: no 作用域: location 该指令设置指定location使用的路径.注意它跟 root 相似,但是不改变文件的根路径,仅仅是使用文件系统路径.比如: location&http://www.aliyun.com/zixun/aggregation/37954.html">nbsp; /i/ {  alias  /spool/w3/i