php稳定性,php redis client 稳定性测试

一直有个想法,做一个只有redis作数据库的系统,一直对redis的功能比较赞赏,但不知道redis的单线程稳定性如何,之前测试过100万Key的写入锁,今天又测试了一下正常读写下redis cli的get稳定性。

结果看起来还可以,2万次左右的单次读取锁0.001秒,如果每次展示需要读取300次cache,整体来说,在redis上的时间损失也不超过0.1秒,跟mysql动则0.1秒的查询效率来看,还是快得多了。

但还不会做redis db集群和数据恢复,学习ing。

官方网站 http://redis.io/

Redis命令 http://redis.io/commands

Redis协议 http://redis.io/topics/protocol

NoSQLFan Redis资料汇总专题 http://blog.nosqlfan.com/html/3537.html

Ubuntu 12.04 Aspire,10G

[shell]

shuhai@Aspire:/wwwroot/php/redis$ cat /proc/meminfo

MemTotal: 10092540 kB

MemFree: 4093172 kB

Buffers: 629836 kB

Cached: 2685732 kB

[/shell]

redis版本

[shell]

shuhai@Aspire:/wwwroot/php/redis$ redis-cli -v

redis-cli 2.2.12

[/shell]

[shell]

shuhai@Aspire:/wwwroot/php/redis$ redis-server -v

Redis server version 2.2.12 (00000000:0)

[/shell]

测试一,读取锁时间

[shell]

shuhai@Aspire:/wwwroot/php/redis$ php locktest.php

60910 => 0.0011389255523682

10954 => 0.0012128353118896

6543 => 0.0011680126190186

599 => 0.0013341903686523

89891 => 0.0011501312255859

20667 => 0.001054048538208

94608 => 0.0011560916900635

127 => 0.0016088485717773

380 => 0.0011329650878906

6977 => 0.0019309520721436

21108 => 0.0011842250823975

31646 => 0.0012660026550293

143386 => 0.0012049674987793

[/shell]

[php]

$redis = new redis;

$redis->connect("tcp://127.0.0.1:6379");

$count = 0;

while(true)

{

$s = microtime(true);

$redis->get('shuhai');

$e = microtime(true);

$t = $e-$s;

$count ++;

if($t > 0.001)

{

echo "$count => $t\n";

$count = 0;

}

}

[/php]

测试二,平均锁读取数量

[shell]

shuhai@Aspire:/wwwroot/php/redis$ php locktest.php

23260

18449.5

40499

30982

32170.6

32801.666666667

33552.428571429

31086.875

27664.333333333

28921.5

27306.545454545

25048.25

23313.923076923

22005.285714286

24101.866666667

26472.0625

25839.764705882

24858.722222222

26115.210526316

25114.75

24149.714285714

29368.954545455

[/shell]

[php]

shuhai@Aspire:/wwwroot/php/redis$ cat locktest.php

$redis = new redis;

$redis->connect("tcp://127.0.0.1:6379");

$count = 0;

while(true)

{

$s = microtime(true);

$redis->get('shuhai');

$e = microtime(true);

$t = $e-$s;

$count ++;

if($t > 0.001)

{

$array[] = $count;

echo array_sum( $array ) / count( $array ) . "\n";

$count = 0;

}

}

[/php]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值