Redis PhpRedis堆栈跟踪

时间:2012-04-18 12:00:34

标签: apache redis stack-trace

出于性能和稳定性的原因,我一直在测试phpredis。性能非常出色,但是我在持续测试后看到了可重复的堆栈跟踪错误 - 通过'ab'运行相同的脚本。

模式运行此测试3到4次

ab -n 10000 -c 10 -k“http:// localhost:84 / index.php rw_app_id = 1& code = test& device_id = test”

(如果我从浏览器运行请求,我似乎无法显示错误,尽管这可能是因为我无法加载进程。)

通常在第3次或第4次迭代期间,Apache错误日志报告以下内容:

Apache错误日志:

[warn] [client 127.0.0.1] mod_fcgid:stderr:PHP致命错误:/var/www/web1/web/index.php:108

[warn] [client 127.0.0.1] mod_fcgid:stderr:堆栈跟踪: [Wed Apr 18 16:39:49 2012] [warn] [client 127.0.0.1] mod_fcgid:stderr:#0 /var/www/web1/web/index.php(108):Redis-> hGet('rw_promo_code :1 ...','unlock_code')

[warn] [client 127.0.0.1] mod_fcgid:stderr:#1 /var/www/web1/web/index.php(172):RedeemAPI-> redeem()

[warn] [client 127.0.0.1] mod_fcgid:stderr:#2 {main}

[warn] [client 127.0.0.1] mod_fcgid:stderr:/var/www/web1/web/index.php:0中的消息'Redis服务器消失'的下一个异常'RedisException'

[warn] [client 127.0.0.1] mod_fcgid:stderr:Stack trace:

[warn] [client 127.0.0.1] mod_fcgid:stderr:#0 /var/www/web1/web/index.php(172):Redis-> __ destruct()

[warn] [client 127.0.0.1] mod_fcgid:stderr:#1 /var/www/web1/web/index.php(172):RedeemAPI-> redeem()

[warn] [client 127.0.0.1] mod_fcgid:stderr:#2 {main}

[warn] [client 127.0.0.1] mod_fcgid:stderr:在第0行的/var/www/web1/web/index.php中抛出

[warn] [client 127.0.0.1] mod_fcgid:stderr:PHP致命错误:/var/www/web1/web/index.php:108

[warn] [client 127.0.0.1] mod_fcgid:stderr:Stack trace:

[warn] [client 127.0.0.1] mod_fcgid:stderr:#0 /var/www/web1/web/index.php(108):Redis-> hGet('rw_promo_code:1 ...','unlock_code')

[warn] [client 127.0.0.1] mod_fcgid:stderr:#1 /var/www/web1/web/index.php(172):RedeemAPI-> redeem()

[warn] [client 127.0.0.1] mod_fcgid:stderr:#2 {main}

[warn] [client 127.0.0.1] mod_fcgid:stderr:/var/www/web1/web/index.php:0中的消息'Redis服务器消失'的下一个异常'RedisException'

[warn] [client 127.0.0.1] mod_fcgid:stderr:Stack trace:

[warn] [client 127.0.0.1] mod_fcgid:stderr:#0 /var/www/web1/web/index.php(172):Redis-> __ destruct()

[warn] [client 127.0.0.1] mod_fcgid:stderr:#1 /var/www/web1/web/index.php(172):RedeemAPI-> redeem()

[warn] [client 127.0.0.1] mod_fcgid:stderr:#2 {main}

[warn] [client 127.0.0.1] mod_fcgid:stderr:在第0行的/var/www/web1/web/index.php中抛出

[warn] [client 127.0.0.1] mod_fcgid:stderr:PHP致命错误:/var/www/web1/web/index.php:108

等...

重启Apache和Redis并重复循环。有时它会再次连接并成功处理一些请求。

我可以尝试捕获异常并尝试重新连接但是进程无法恢复。

Ubuntu x86_64 11.10 Redis版本2.4 Apache / 2.2.20(Ubuntu) mod_fastcgi / mod_fastcgi-SNAP-0910052141 mod_fcgid / 2.3.6 mod_perl / 2.0.5 Perl / v5.12.4

1 个答案:

答案 0 :(得分:0)

https://github.com/antirez/redis/issues/340上找到了这个:

这可能是因为操作系统没有足够快地清理连接。如果为redis-benchmark禁用keepalive,则会发出以下警告,但同样适用于运行循环基准测试:

警告:禁用keepalive,您可能需要

echo 1> / proc / sys / net / ipv4 / tcp_tw_reuse for Linux和

sudo sysctl -w net.inet.tcp.msl = 1000 for Mac OS X,以便使用大量客户端/请求

我对此进行了测试并且有所帮助 - 但是我仍然遇到了错误

[warn] [client 127.0.0.1](104)通过对等方重置连接:mod_fcgid:从FastCGI服务器读取数据时出错 [error] [client 127.0.0.1]脚本头的过早结束:index.php

更新

已经测试了1,000,000个请求 - 一次10个 - 没有错误。