ngx信息如下:
[root@176qing vhost]# /usr/local/nginx/sbin/nginx -V
nginx version: ngx_openresty/1.2.7.8
built by gcc 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --add-module=../ngx_devel_kit-0.2.18 --add-module=../echo-nginx-module-0.45 --add-module=../xss-nginx-module-0.03rc9 --add-module=../ngx_coolkit-0.2rc1 --add-module=../set-misc-nginx-module-0.22rc8 --add-module=../form-input-nginx-module-0.07 --add-module=../encrypted-session-nginx-module-0.03 --add-module=../srcache-nginx-module-0.19 --add-module=../ngx_lua-0.7.21 --add-module=../headers-more-nginx-module-0.19 --add-module=../array-var-nginx-module-0.03rc1 --add-module=../memc-nginx-module-0.13rc3 --add-module=../redis2-nginx-module-0.10 --add-module=../redis-nginx-module-0.3.6 --add-module=../auth-request-nginx-module-0.2 --add-module=../rds-json-nginx-module-0.12rc10 --add-module=../rds-csv-nginx-module-0.05rc2 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-http_stub_status_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_realip_module --with-http_secure_link_module --with-http_gzip_static_module --with-http_ssl_module --with-google_perftools_module --with-pcre=/root/ngx_openresty-1.2.7.8/../pcre-8.31
其中有一个高频的URI,每日请求大概500w次的样子。
功能大概是POST上来,然后通过lua-resty-mysql去查询信息,返回。
不打开luaJIT时:
Active connections: 10140
server accepts handled requests
817012 817012 3328083
Reading: 417 Writing: 18 Waiting: 9705
[root@vip qing]# curl localhost/openapi/message -I
HTTP/1.1 200 OK
Server: ngx_openresty/1.2.7.8
Date: Thu, 11 Jul 2013 09:19:11 GMT
Content-Type: text/json
Connection: keep-alive
使用luaJIT后
Active connections: 3524
其它省略...
[root@vip qing]# curl localhost/openapi/message -I
HTTP/1.1 405 Not Allowed
Date: Thu, 11 Jul 2013 09:19:15 GMT
Content-Type: application/_javascript_
Connection: keep-alive
Content-Length: 67
Server: openresty lua handler
提问:
1) 请求量不变,Active connections减少了,应该是keep-alive没生效? 还是其它原因.
2) 连接减少的原因是什么?才服务器来说tcp少了,压力肯定好了点,但对客户端来说是否就意味着没使用到keep-alive?
因为后者多输出了一个Content-Length头,使keep-alive失效吗?