memtier_benchmark の導入 (memcached-tool で Slab の内容確認)

Redis本を執筆しました。Memcachedとの詳細な比較も付録で取り上げていますので、こちらも是非合わせてご覧ください。

———————————————————————————————————————————————————

memtier_benchmarkのインストール

必要なライブラリのインストール

$ sudo yum install autoconf automake gcc-c++ libevent-devel openssl-devel -y

memtier_benchmarkのインストール

$ git clone https://github.com/RedisLabs/memtier_benchmark.git
$ cd memtier_benchmark
$ autoreconf -ivf
$ ./configure --prefix=/usr/
$ make
$ sudo make install

インストールされていることも確認できるようになります。

$ memtier_benchmark -v
memtier_benchmark 1.3.0
Copyright (C) 2011-2020 Redis Labs Ltd.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

ヘルプも確認できます。

$ memtier_benchmark -h
Usage: memtier_benchmark [options]
A memcache/redis NoSQL traffic generator and performance benchmarking tool.

Connection and General Options:
  -s, --server=ADDR              Server address (default: localhost)
  -p, --port=PORT                Server port (default: 6379)
  -S, --unix-socket=SOCKET       UNIX Domain socket name (default: none)
  -P, --protocol=PROTOCOL        Protocol to use (default: redis).  Other
                                 supported protocols are memcache_text,
                                 memcache_binary.
  -a, --authenticate=CREDENTIALS Authenticate using specified credentials.
                                 A simple password is used for memcache_text
                                 and Redis <= 5.x. <USER>:<PASSWORD> can be
                                 specified for memcache_binary or Redis 6.x
                                 or newer with ACL user support.
      --tls                      Enable SSL/TLS transport security
      --cert=FILE                Use specified client certificate for TLS
      --key=FILE                 Use specified private key for TLS
      --cacert=FILE              Use specified CA certs bundle for TLS
      --tls-skip-verify          Skip verification of server certificate
      --sni=STRING               Add an SNI header
  -x, --run-count=NUMBER         Number of full-test iterations to perform
  -D, --debug                    Print debug output
      --client-stats=FILE        Produce per-client stats file
  -o, --out-file=FILE            Name of output file (default: stdout)
      --json-out-file=FILE       Name of JSON output file, if not set, will not print to json
      --hdr-file-prefix=FILE     Prefix of HDR Latency Histogram output files, if not set, will not save latency histogram files
      --show-config              Print detailed configuration before running
      --hide-histogram           Don't print detailed latency histogram
      --print-percentiles        Specify which percentiles info to print on the results table (by default prints percentiles: 50,99,99.9)
      --cluster-mode             Run client in cluster mode
  -h, --help                     Display this help
  -v, --version                  Display version information

Test Options:
  -n, --requests=NUMBER          Number of total requests per client (default: 10000)
                                 use 'allkeys' to run on the entire key-range
  -c, --clients=NUMBER           Number of clients per thread (default: 50)
  -t, --threads=NUMBER           Number of threads (default: 4)
      --test-time=SECS           Number of seconds to run the test
      --ratio=RATIO              Set:Get ratio (default: 1:10)
      --pipeline=NUMBER          Number of concurrent pipelined requests (default: 1)
      --reconnect-interval=NUM   Number of requests after which re-connection is performed
      --multi-key-get=NUM        Enable multi-key get commands, up to NUM keys (default: 0)
      --select-db=DB             DB number to select, when testing a redis server
      --distinct-client-seed     Use a different random seed for each client
      --randomize                random seed based on timestamp (default is constant value)

Arbitrary command:
      --command=COMMAND          Specify a command to send in quotes.
                                 Each command that you specify is run with its ratio and key-pattern options.
                                 For example: --command="set __key__ 5" --command-ratio=2 --command-key-pattern=G
                                 To use a generated key or object, enter:
                                   __key__: Use key generated from Key Options.
                                   __data__: Use data generated from Object Options.
      --command-ratio            The number of times the command is sent in sequence.(default: 1)
      --command-key-pattern      Key pattern for the command (default: R):
                                 G for Gaussian distribution.
                                 R for uniform Random.
                                 S for Sequential.
                                 P for Parallel (Sequential were each client has a subset of the key-range).

Object Options:
  -d  --data-size=SIZE           Object data size (default: 32)
      --data-offset=OFFSET       Actual size of value will be data-size + data-offset
                                 Will use SETRANGE / GETRANGE (default: 0)
  -R  --random-data              Indicate that data should be randomized
      --data-size-range=RANGE    Use random-sized items in the specified range (min-max)
      --data-size-list=LIST      Use sizes from weight list (size1:weight1,..sizeN:weightN)
      --data-size-pattern=R|S    Use together with data-size-range
                                 when set to R, a random size from the defined data sizes will be used,
                                 when set to S, the defined data sizes will be evenly distributed across
                                 the key range, see --key-maximum (default R)
      --expiry-range=RANGE       Use random expiry values from the specified range

Imported Data Options:
      --data-import=FILE         Read object data from file
      --data-verify              Enable data verification when test is complete
      --verify-only              Only perform --data-verify, without any other test
      --generate-keys            Generate keys for imported objects
      --no-expiry                Ignore expiry information in imported data

Key Options:
      --key-prefix=PREFIX        Prefix for keys (default: "memtier-")
      --key-minimum=NUMBER       Key ID minimum value (default: 0)
      --key-maximum=NUMBER       Key ID maximum value (default: 10000000)
      --key-pattern=PATTERN      Set:Get pattern (default: R:R)
                                 G for Gaussian distribution.
                                 R for uniform Random.
                                 S for Sequential.
                                 P for Parallel (Sequential were each client has a subset of the key-range).
      --key-stddev               The standard deviation used in the Gaussian distribution
                                 (default is key range / 6)
      --key-median               The median point used in the Gaussian distribution
                                 (default is the center of the key range)

WAIT Options:
      --wait-ratio=RATIO         Set:Wait ratio (default is no WAIT commands - 1:0)
      --num-slaves=RANGE         WAIT for a random number of slaves in the specified range
      --wait-timeout=RANGE       WAIT for a random number of milliseconds in the specified range (normal 
                                 distribution with the center in the middle of the range)

以下のようにして実行できます。--out-file=オプションや--json-out-file=オプションで、テキストファイルやJSONファイルに結果を出力することもできます。接続数等の設定値によってはroot権限が求められることもあります。

Redisの場合は以下のように実行します。

$ memtier_benchmark \
-s xxxxxxxxxx.xxxxxx.ng.0001.apne1.cache.amazonaws.com -p 6379 -P redis \
--threads 16 -c 10000 \
--test-time=3600 --key-prefix=key1: —data-size=100 \
--key-maximum=99999 \
--key-minimum=10000 \
--ratio=2:10 \
--print-percentiles="50,95,99,99.9"

Memcachedの場合は以下のように実行します。バイナリモードでテストする場合は-Pオプションにmemcache_textを指定します。

$ memtier_benchmark \
-s xxxxxxxxxx.xxxxxx.0001.apne1.cache.amazonaws.com -p 11211 -P memcache_text \
--threads 16 -c 10000 \
--test-time=3600 --key-prefix=key1: —data-size=100 \
--key-maximum=99999 \
--key-minimum=10000 \
--ratio=2:10 \
--print-percentiles="50,95,99,99.9"

以下のような結果が確認できます。

ALL STATS
============================================================================================================================================
Type         Ops/sec     Hits/sec   Misses/sec    Avg. Latency     p50 Latency     p95 Latency     p99 Latency   p99.9 Latency       KB/sec 
--------------------------------------------------------------------------------------------------------------------------------------------
Sets        18343.80          ---          ---         1.81964         1.68700         2.55900         2.79900         6.23900      1325.63 
Gets        91687.49      2825.74     88861.75         1.81555         1.68700         2.54300         2.78300         6.17500      3227.67 
Waits           0.00          ---          ---             ---             ---             ---             ---             ---          --- 
Totals     110031.30      2825.74     88861.75         1.81623         1.68700         2.54300         2.78300         6.20700      4553.30 


Request Latency Distribution
Type     <= msec         Percent
------------------------------------------------------------------------
SET       0.479         0.00
SET       1.327         5.00
SET       1.423        10.00
SET       1.479        15.00
:

memcached-toolのインストール

memcached-toolはMemcachedに同梱しています。そのため、Memcachedをインストールします。

$ sudo yum install memcached -y

以下のように使い方を確認できます。

$ memcached-tool
Usage: memcached-tool <host[:port] | /path/to/socket> [mode]

       memcached-tool 10.0.0.5:11211 display    # shows slabs
       memcached-tool 10.0.0.5:11211            # same.  (default is display)
       memcached-tool 10.0.0.5:11211 stats      # shows general stats
       memcached-tool 10.0.0.5:11211 dump       # dumps keys and values

以下のコマンドのように実行することで確認できます。スラブクラスごとの状況が確認できます。

$ memcached-tool xxxxxxxxxx.xxxxxx.ng.0001.apne1.cache.amazonaws.com:11211
  #  Item_Size  Max_age   Pages   Count   Full?  Evicted Evict_Time OOM
  2     120B       229s       1    1619     yes        0        0    0

参照

My Twitter & RSS

Leave a Reply

Your email address will not be published. Required fields are marked *