Last active
February 9, 2018 09:20
-
-
Save shield-9/3b0b0b51635eac30b34ee4b4cdf05854 to your computer and use it in GitHub Desktop.
Redis Benchmark in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cluster = new RedisCluster(NULL, [ | |
'cluster-1:7000', 'cluster-2:7000', | |
'cluster-3:7000', 'cluster-4:7000', | |
'cluster-5:7000', | |
]); | |
for ($i = 0; $i < 1000000; $i++) { | |
$cluster->get($i); | |
} | |
$cluster->close(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
for ($i = 0; $i < 1000000; $i++) { | |
$cluster = new RedisCluster(NULL, [ | |
'cluster-1:7000', 'cluster-2:7000', | |
'cluster-3:7000', 'cluster-4:7000', | |
'cluster-5:7000', | |
]); | |
$cluster->get(mt_rand(1, 100000)); | |
$cluster->close(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$prefix = mt_rand(1000, 9999); | |
$cluster = new RedisCluster(NULL, [ | |
'cluster-1:7000', 'cluster-2:7000', | |
'cluster-3:7000', 'cluster-4:7000', | |
'cluster-5:7000', | |
]); | |
for ($i = 0; $i < 1000000; $i++) { | |
$cluster->set($prefix . "-" . $i, $i); | |
} | |
$cluster->close(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
for ($i = 0; $i < 1000000; $i++) { | |
$cluster = new RedisCluster(NULL, [ | |
'cluster-1:7000', 'cluster-2:7000', | |
'cluster-3:7000', 'cluster-4:7000', | |
'cluster-5:7000', | |
]); | |
$cluster->set(mt_rand(1, 100000), mt_rand()); | |
$cluster->close(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# テストの実行 (5並列; 実行するマシンはtesterファイルに記述してあります。) | |
parallel-ssh -i -h testers -x "-i ~/.ssh/mykey.pem" -t 0 "nohup bash -c 'ulimit-n 65536; (time php benchmark/benchmark_set.php) >> result 2>&1' &" & | |
parallel-ssh -i -h testers -x "-i ~/.ssh/mykey.pem" -t 0 "nohup bash -c 'ulimit-n 65536; (time php benchmark/benchmark_set.php) >> result 2>&1' &" & | |
parallel-ssh -i -h testers -x "-i ~/.ssh/mykey.pem" -t 0 "nohup bash -c 'ulimit-n 65536; (time php benchmark/benchmark_set.php) >> result 2>&1' &" & | |
parallel-ssh -i -h testers -x "-i ~/.ssh/mykey.pem" -t 0 "nohup bash -c 'ulimit-n 65536; (time php benchmark/benchmark_set.php) >> result 2>&1' &" & | |
parallel-ssh -i -h testers -x "-i ~/.ssh/mykey.pem" -t 0 "nohup bash -c 'ulimit-n 65536; (time php benchmark/benchmark_set.php) >> result 2>&1' &" & | |
# 実行中の様子 | |
parallel-ssh -i -h testers -x "-i ~/.ssh/mykey.pem" -t 0 "ps aux | grep php | grep -v bash | grep -v grep | wc -l" | |
# 結果を見る | |
parallel-ssh -i -h testers -x "-i ~/.ssh/mykey.pem" -t 0 "cat result" | grep real | |
# 結果のリセット | |
parallel-ssh -i -h testers -x "-i ~/.ssh/mykey.pem" -t 0 "rm result" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cluster = new RedisCluster(NULL, [ | |
'cluster-1:7000', 'cluster-2:7000', | |
'cluster-3:7000', 'cluster-4:7000', | |
'cluster-5:7000', | |
]); | |
$error = 0; | |
for ($i = 0; $i < 1000000; $i++) { | |
$key = mt_rand(1, 100000); | |
$value = mt_rand(); | |
$cluster->set($key, $value); | |
if ($value != $cluster->get($key)) { | |
++$error; | |
} | |
} | |
printf("[Set/Get Test] Error Rate: %f", $error / 100000); | |
$cluster->close(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
admin@tester-1 | |
admin@tester-2 | |
admin@tester-3 | |
admin@tester-4 | |
admin@tester-5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment