redis memcache 性能测试

来源:互联网 发布:异或 c语言 编辑:程序博客网 时间:2024/05/27 14:11

  $m = new Memcached();
    $m->addServer('127.0.0.1',11211);
    for($i=0;$i<1000;$i++){
         //$m->set($i,microtime());
          $m->get($i);
    }
    $r = new Redis;
    $r->connect('127.0.0.1',6379);
     for($i=0;$i<1000;$i++){
         //$r->set($i,microtime());
          $r->get($i);
    }
    

//redis get

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)




Server Software:        nginx/1.9.4
Server Hostname:        localhost
Server Port:            80


Document Path:          /test/test.php
Document Length:        0 bytes


Concurrency Level:      100
Time taken for tests:   47.997 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      147000 bytes
HTML transferred:       0 bytes
Requests per second:    20.83 [#/sec] (mean)
Time per request:       4799.664 [ms] (mean)
Time per request:       47.997 [ms] (mean, across all concurrent requests)
Transfer rate:          2.99 [Kbytes/sec] received


Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.6      0       6
Processing:   103 4646 737.0   4787    6722
Waiting:       97 4646 737.0   4787    6722
Total:        103 4646 736.0   4787    6722


Percentage of the requests served within a certain time (ms)
  50%   4787
  66%   4814
  75%   4822
  80%   4849
  90%   4925
  95%   5343
  98%   6071
  99%   6128

 100%   6722 (longest request)



//redis set

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)




Server Software:        nginx/1.9.4
Server Hostname:        localhost
Server Port:            80


Document Path:          /test/test.php
Document Length:        0 bytes


Concurrency Level:      100
Time taken for tests:   51.391 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      147000 bytes
HTML transferred:       0 bytes
Requests per second:    19.46 [#/sec] (mean)
Time per request:       5139.068 [ms] (mean)
Time per request:       51.391 [ms] (mean, across all concurrent requests)
Transfer rate:          2.79 [Kbytes/sec] received


Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.3      0       6
Processing:    92 4975 728.6   5115    7040
Waiting:       86 4975 728.6   5115    7040
Total:         92 4975 727.6   5115    7040


Percentage of the requests served within a certain time (ms)
  50%   5115
  66%   5163
  75%   5207
  80%   5213
  90%   5231
  95%   5253
  98%   6202
  99%   6579
 100%   7040 (longest request)


//memcache get

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)




Server Software:        nginx/1.9.4
Server Hostname:        localhost
Server Port:            80


Document Path:          /test/test.php
Document Length:        0 bytes


Concurrency Level:      100
Time taken for tests:   23.268 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      147000 bytes
HTML transferred:       0 bytes
Requests per second:    42.98 [#/sec] (mean)
Time per request:       2326.798 [ms] (mean)
Time per request:       23.268 [ms] (mean, across all concurrent requests)
Transfer rate:          6.17 [Kbytes/sec] received


Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.1      0       6
Processing:    68 2246 802.2   2073    3578
Waiting:       63 2246 802.2   2073    3578
Total:         68 2247 801.8   2073    3578


Percentage of the requests served within a certain time (ms)
  50%   2073
  66%   2900
  75%   3030
  80%   3111
  90%   3265
  95%   3352
  98%   3430
  99%   3456
 100%   3578 (longest request)


//memcache set

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)




Server Software:        nginx/1.9.4
Server Hostname:        localhost
Server Port:            80


Document Path:          /test/test.php
Document Length:        0 bytes


Concurrency Level:      100
Time taken for tests:   30.619 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      147000 bytes
HTML transferred:       0 bytes
Requests per second:    32.66 [#/sec] (mean)
Time per request:       3061.896 [ms] (mean)
Time per request:       30.619 [ms] (mean, across all concurrent requests)
Transfer rate:          4.69 [Kbytes/sec] received


Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.9      0       8
Processing:    58 2966 653.7   2989    4569
Waiting:       44 2966 653.7   2989    4569
Total:         59 2967 652.7   2989    4569


Percentage of the requests served within a certain time (ms)
  50%   2989
  66%   3128
  75%   3288
  80%   3368
  90%   3814
  95%   4125
  98%   4336
  99%   4432
 100%   4569 (longest request)



+session stored

 ini_set('session.gc_maxlifetime', 3600);
ini_set("session.save_handler","redis");
ini_set("session.save_path","tcp://127.0.0.1:6379");
 session_start();
$_SESSION['session'] = 'this is session content!';
//echo $_SESSION['session'];
//echo session_id().'<br/>';
// 
//$redis = new redis();
//$redis->connect('127.0.0.1', 6379);
////redis用session_id作为key并且是以string的形式存储
//echo $redis->get('PHPREDIS_SESSION:' . session_id());
   /*PHPREDIS_SESSION+session_id()*/
/*
 * This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)




Server Software:        nginx/1.9.4
Server Hostname:        localhost
Server Port:            80


Document Path:          /test/test.php
Document Length:        2 bytes


Concurrency Level:      50
Time taken for tests:   0.880 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      344000 bytes
HTML transferred:       2000 bytes
Requests per second:    1136.97 [#/sec] (mean)
Time per request:       43.977 [ms] (mean)
Time per request:       0.880 [ms] (mean, across all concurrent requests)
Transfer rate:          381.95 [Kbytes/sec] received


Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   4.2      0      23
Processing:     2   42  10.4     44      60
Waiting:        0   42  10.5     44      60
Total:          5   43   8.4     44      60


Percentage of the requests served within a certain time (ms)
  50%     44
  66%     47
  75%     49
  80%     49
  90%     52
  95%     59
  98%     59
  99%     59
 100%     60 (longest request)


 */
ini_set("session.save_handler", "memcache"); 
ini_set("session.save_path", "tcp://127.0.0.1:11211"); 
session_start(); 
$_SESSION[$i] = time();
/*
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)




Server Software:        nginx/1.9.4
Server Hostname:        localhost
Server Port:            80


Document Path:          /test/test.php
Document Length:        2 bytes


Concurrency Level:      50
Time taken for tests:   11.352 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      344000 bytes
HTML transferred:       2000 bytes
Requests per second:    88.09 [#/sec] (mean)
Time per request:       567.596 [ms] (mean)
Time per request:       11.352 [ms] (mean, across all concurrent requests)
Transfer rate:          29.59 [Kbytes/sec] received


Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0       5
Processing:    19  559 104.2    559     991
Waiting:       15  559 104.2    559     991
Total:         19  559 103.9    559     991


Percentage of the requests served within a certain time (ms)
  50%    559
  66%    593
  75%    616
  80%    629
  90%    672
  95%    713
  98%    776
  99%    798
 100%    991 (longest request)
 * 
 */

0 0
原创粉丝点击