出于性能和稳定性的原因,我一直在测试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错误日志:
警告mod_fcgid: stderr: PHP致命错误:/var/www/web 1/web/index.php:108中带有“Redis服务器消失”消息的未命名异常'RedisException‘
警告mod_fcgid: stderr:堆栈跟踪:rw 18 16:39:49 2012 client 127.0.0.1 mod_fcgid:#0 /var/www/web 1/web/index.php(108):Redis->hGet(‘rw_promo_code:1.’,'unlock_code')
警告mod_fcgid: stderr:#1 /var/www/web 1/web/index.php(172):RedeemAPI->redeem()
警告mod_fcgid: stderr:#2 {main}
警告mod_fcgid: stderr: /var/www/web 1/web/index.php:0中的下一个异常'RedisException‘和消息'Redis服务器消失’
警告mod_fcgid: stderr:堆栈跟踪:
警告mod_fcgid: stderr:#0 /var/www/web 1/web/index.php(172):Redis->_destruct()
警告mod_fcgid: stderr:#1 /var/www/web 1/web/index.php(172):RedeemAPI->redeem()
警告mod_fcgid: stderr:#2 {main}
警告mod_fcgid: stderr:抛入第0行的/var/www/web 1/web/index.php
警告mod_fcgid: stderr: PHP致命错误:/var/www/web 1/web/index.php:108中带有“Redis服务器消失”消息的未命名异常'RedisException‘
警告mod_fcgid: stderr:堆栈跟踪:
警告mod_fcgid: stderr:#0 /var/www/web 1/web/index.php(108):Redis->hGet(‘rw_promo_code:1.’,'unlock_code')
警告mod_fcgid: stderr:#1 /var/www/web 1/web/index.php(172):RedeemAPI->redeem()
警告mod_fcgid: stderr:#2 {main}
警告mod_fcgid: stderr: /var/www/web 1/web/index.php:0中的下一个异常'RedisException‘和消息'Redis服务器消失’
警告mod_fcgid: stderr:堆栈跟踪:
警告mod_fcgid: stderr:#0 /var/www/web 1/web/index.php(172):Redis->_destruct()
警告mod_fcgid: stderr:#1 /var/www/web 1/web/index.php(172):RedeemAPI->redeem()
警告mod_fcgid: stderr:#2 {main}
警告mod_fcgid: stderr:抛入第0行的/var/www/web 1/web/index.php
警告mod_fcgid: stderr: PHP致命错误:/var/www/web 1/web/index.php:108中带有“Redis服务器消失”消息的未命名异常'RedisException‘
等等..。
重新启动Apache和Redis,并可以重复这个循环。有时它会再次连接并成功地处理一些请求。
我可以尝试捕获异常并尝试重新连接,但是进程无法恢复。
Ubuntu x86_64 11.10 Redis版本2.4 Apache/2.2.20 (Ubuntu) mod_/mod_x86_64 fcgid SNAP-0910052141 mod_fcgid/2.3.6 mod_Perl/2.0.5perl/v5.12.4
发布于 2012-04-19 03:18:10
在https://github.com/antirez/redis/issues/340上找到了这个
这很可能是因为操作系统没有足够快地清理连接。以下警告是在redis-benchmark禁用“保持活动”时发出的,但对于运行循环基准测试也是如此:
警告:残废保持生命,您可能需要
echo 1>/proc/sys/net/ipv4 4/tcp_tw_重用用于Linux和
sudo sysctl -w net.inet.tcp.msl=1000 for Mac OS X,以便使用大量的客户端/请求
我对此进行了测试,这是有帮助的--但是我仍然犯了很多错误。
警告(104)连接重置: mod_fcgid:从FastCGI服务器读取数据时出错--脚本头的过早结束: index.php
更新:
测试了1,000,000次请求--每次10次--没有错误。
https://stackoverflow.com/questions/10208924
复制相似问题