Linux ubuntu 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:50:42 UTC 2011 i686 i686 i386 GNU/Linux
------------------ 原始邮件 ------------------
发送时间: 2012年3月31日(星期六) 中午11:40
收件人: "mmxcq";
抄送: "openresty";
主题: Re: 回复: 回复: 回复: 你好 我是在网上看见这篇文章 然后测试了你的模块
n Sat, Mar 31, 2012 at 10:43 AM, mmxcq <
sunmmx@gmail.com> wrote:
> root@ubuntu:~# cat /usr/local/nginx/logs/error.log
> 2012/03/31 10:27:31 [notice] 3058#0: signal process started
> root@ubuntu:~# cat /usr/local/nginx/logs/error.log
> 2012/03/31 10:27:31 [notice] 3058#0: signal process started
> root@ubuntu:~# ab -c 100 -n 1000000 -k
http://test.com/[...]
>
> 你好 没有发现日志里面有什么错误 为了不干扰以前的日志 我把日志清空了 重新测试
> 1086
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1088
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1088
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1088
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1088
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1090
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1090
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1090
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1110
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1132
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1136
> root@ubuntu:~# cat /tmp/q.txt |wc -l
> 1138
> root@ubuntu:~#
> 谢谢你耐心的回复
为了避免 ngx_fastcgi, php-fpm 等组件对这里测试的干扰,我在我本地使用了下面这个最小化的测试例子,并使用 nginx
1.0.11 + ngx_srcache 0.13rc6 + ngx_memc 0.13rc3 + ngx_lua
0.5.0rc21,无法复现你描述的问题:
upstream memc {
server 127.0.0.1:11211;
keepalive 1024 single;
}
server {
listen 1984;
keepalive_timeout 68;
location /foo {
default_type text/css;
srcache_fetch GET /memc $uri;
srcache_store PUT /memc $uri;
content_by_lua '
os.execute("echo `date` >> /tmp/out")
ngx.header.content_length = 6
ngx.say("hello");
';
}
location /memc {
internal;
set $memc_key $query_string;
set $memc_exptime 36000;
memc_pass memc;
}
这里我使用了内联 Lua 代码来做你的 PHP 脚本所类似的事情,向 /tmp/out 临时文件追加当前日期和时间。然后先访问一下
/foo 接口以确保内容缓存住:
$ curl localhost:1984/foo
接下来使用 ab 进行压测:
$ ab -k -c100 -n1000000 localhost:1984/foo
结果 /tmp/out 总是保持 1 行:
$ wc -l /tmp/out
1
我的操作系统是 Slackware Linux x86_64, kernel 2.6.33.1. ApacheBench (ab) 的版本是 2.3.
你能确保你使用的 ab、nginx 及各模版的版本都比我上面使用的新么?同时你能尝试一下我上面这个例子么?另外,你使用的是 32 位
ubuntu 还是 64 位的?
Thanks!
-agentzh