在并发写的同时,并发读。yac出现读取数据失败,基本到了不可用的地步
yyxx9988 opened this issue · comments
yac和memcache性能对比测试 https://yq.aliyun.com/articles/27323 这里是详细过程@laruence 鸟哥看下是咋回事?
<?php
function test_memcache_set(){
$mem = memcache_connect('127.0.0.1', 11211);
$value = mt_rand();
$res = memcache_set($mem, 'var_key', $value, false, 3000);
var_dump($res);
if (!$res) {
header("HTTP/1.0 404 Not Found");
}
}
function test_memcache_get(){
$mem = memcache_connect('127.0.0.1', 11211);
$res = memcache_get($mem, 'var_key');
var_dump($res);
if (!$res) {
header("HTTP/1.0 404 Not Found");
} else {
echo $res;
}
}
function test_yac_set(){
$yac = new Yac();
$value = mt_rand();
$res = $yac->set('var_key', $value);
var_dump($res);
if (!$res) {
header("HTTP/1.0 404 Not Found");
}
}
function test_yac_get(){
$yac = new Yac();
$res = $yac->get('var_key');
var_dump($res);
if (!$res) {
header("HTTP/1.0 404 Not Found");
} else {
echo $res;
}
}
echo $_GET["m"]();
?>
ab -t 10 -c 20 http://10.32.232.129/test.php?m=test_yac_get
Complete requests: 1220
Failed requests: 829
(Connect: 0, Length: 829, Exceptions: 0)
Time per request: 164.116 [ms] (mean)
Complete requests: 1300
Failed requests: 809
(Connect: 0, Length: 809, Exceptions: 0)
Time per request: 154.907 [ms] (mean)
核心的点你要搞清楚Yac适用的场景, 那就是要求这个场景下出现多个进程同时写一个Key的概率比较小...
所以正确的测试应该是, 脚本随机生成一个key名, 写入, 然后读取回来看看对不对...
建议你看看这篇文章哈: http://www.laruence.com/2013/03/18/2846.html
thanks
原来是这样。。。突然发现“信海龙”这个名字咋这么熟悉?好像在微博上看见过。鸟哥,这家伙抹黑你的yac,快用渣浪wb反击他~
没有啊, 按照他设计的测试场景, 这样的结论也很正确