Redis
 sql >> Teknologi Basis Data >  >> NoSQL >> Redis

Redis benchmarking untuk perintah hget dan hset

Saya baru menyadari redis-benchmark perintah tidak membandingkan hSet dan hGet perintah. (Saya menggunakan v2.8.5)

Yang dapat Anda lakukan adalah menulis program kecil untuk membandingkan kinerja:

<?php

$redis = new Redis();
$redis->pconnect("127.0.0.1");

$count = 10000;

$start_t = microtime(true);
for ($i = 1; $i < $count; $i++) {
    $redis->hSet("h{$i}", 'f', $i);
}
$end_t = microtime(true);

echo "Time taken for hSet = " . round(1000 * ($end_t - $start_t)) . "ms (for " . number_format($count) . " keys)\n";

$start_t = microtime(true);
$pipeline1 = $redis->pipeline();
for ($i = 1; $i < $count; $i++) {
    $pipeline1->hSet("h{$i}", 'f', $i);
}
$result2 = $pipeline1->exec();
$end_t = microtime(true);

echo "Time taken for hSet (bulk) = " . round(1000 * ($end_t - $start_t)) . "ms (for " . number_format($count) . " keys)\n";

$start_t = microtime(true);
for ($i = 1; $i < $count; $i++) {
    $redis->hGet("h{$i}", 'f');
}
$end_t = microtime(true);

echo "Time taken for hGet = " . round(1000 * ($end_t - $start_t)) . "ms (for " . number_format($count) . " keys)\n";

$start_t = microtime(true);
$pipeline2 = $redis->pipeline();
for ($i = 1; $i < $count; $i++) {
    $pipeline2->hGet("h{$i}", 'f');
}
$result2 = $pipeline2->exec();
$end_t = microtime(true);

echo "Time taken for hGet (bulk) = " . round(1000 * ($end_t - $start_t)) . "ms (for " . number_format($count) . " keys)\n";


$start_t = microtime(true);
$pipeline3 = $redis->pipeline();
for ($i = 1; $i < $count; $i++) {
    $pipeline3->hDel("h{$i}", 'f');
}
$result3 = $pipeline3->exec();
$end_t = microtime(true);

echo "Time taken for hDel (bulk) = " . round(1000 * ($end_t - $start_t)) . "ms (for " . number_format($count) . " keys)\n";

Di server pengujian saya, hasilnya adalah sebagai berikut:

$ php redis/benchmark_redis.php Time taken for hSet = 557ms (for 10,000 keys) Time taken for hSet (bulk) = 51ms (for 10,000 keys) Time taken for hGet = 483ms (for 10,000 keys) Time taken for hGet (bulk) = 43ms (for 10,000 keys) Time taken for hDel (bulk) = 49ms (for 10,000 keys)



  1. Redis
  2.   
  3. MongoDB
  4.   
  5. Memcached
  6.   
  7. HBase
  8.   
  9. CouchDB
  1. Pengumpulan Koneksi Redis Node.js

  2. Basis data noSQL mana yang terbaik untuk penyisipan/penulisan volume tinggi?

  3. Tidak dapat memperoleh hasil dari Redis menggunakan Crud Repository di Spring Boot?

  4. Memecahkan masalah

  5. StackExchange.Redis.RedisTimeoutException:Batas waktu menunggu tanggapan