Redis パフォーマンステスト

Redis パフォーマンステストは、複数のコマンドを同時に実行することで実現されます。

構文

redis パフォーマンステストの基本コマンドは次のとおりです:

redis-benchmark [option] [option value]

注意:このコマンドは redis のディレクトリで実行されるものであり、redis クライアントの内部コマンドではありません。

サンプル

以下の例では、10000 個のリクエストを同時に実行してパフォーマンスをテストします:

$ redis-benchmark -n 10000  -q

PING_INLINE: 141043.72 requests per second
PING_BULK: 142857.14 requests per second
SET: 141442.72 requests per second
GET: 145348.83 requests per second
INCR: 137362.64 requests per second
LPUSH: 145348.83 requests per second
LPOP: 146198.83 requests per second
SADD: 146198.83 requests per second
SPOP: 149253.73 requests per second
LPUSH (needed to benchmark LRANGE): 148588.42 requests per second
LRANGE_100 (first 100 elements): 58411.21 requests per second
LRANGE_300 (first 300 elements): 21195.42 requests per second
LRANGE_500 (first 450 elements): 14539.11 requests per second
LRANGE_600 (first 600 elements): 10504.20 requests per second
MSET (10 keys): 93283.58 requests per second

redis パフォーマンステストツールのオプションパラメータは次のとおりです:

番号オプション説明デフォルト値
1 -h サーバーのホスト名を指定 127.0.0.1
2 -p サーバーのポートを指定 6379
3 -s サーバーのソケットを指定
4 -c 同時接続数を指定 50
5 -n リクエスト数を指定 10000
6 -d SET/GET 値のデータサイズをバイト単位で指定 2
7 -k 1=keep alive 0=reconnect 1
8 -r SET/GET/INCR はランダムなキーを使用し、SADD はランダムな値を使用
9 -P パイプラインで <numreq> リクエストを送信 1
10 -q redis を強制終了します。query/sec 値のみを表示
11 --csv CSV 形式で出力
12 -l(L の小文字) ループを生成し、テストを永久に実行
13 -t カンマ区切りのテストコマンドリストのみを実行します。
14 -I(i の大文字) Idle モード。N 個のアイドル接続を開いて待機します。

サンプル

以下の例では、複数のパラメータを使用して redis のパフォーマンスをテストしました:

$ redis-benchmark -h 127.0.0.1 -p 6379 -t set,lpush -n 10000 -q

SET: 146198.83 requests per second
LPUSH: 145560.41 requests per second

上記の例では、ホストは 127.0.0.1、ポート番号は 6379、実行したコマンドは set,lpush、リクエスト数は 10000 で、-q パラメータにより結果には毎秒実行されるリクエスト数のみが表示されます。

その他の拡張