がらくたネット

アフィリエイト広告を利用しています


SysBenck

SysBenck

SysBenchはサーバーのベンチマークソフト

ベンチマーク対象は以下

  • file I/O performance
  • scheduler performance
  • memory allocation and transfer speed
  • POSIX threads implementation performance
  • database server performance

インストール

インストールは至って簡単

# ./configure
# ./autogen.sh
# make
# make check
# make install

libtoolでエラーが発生する場合がある(SL6.1とか) その場合は、makeする前にディレクトリにあるlibtoolを削除してOS標準のlibtoolをシンボリックリンクとして設定しておけば吉。

mv libtool libtool.org
ln -s /usr/bin/libtool libtool

普通にmakeするとlibtoolがエラーをはく。これはautoconfの問題だという事らしい

インストール要件としては以下

  • MySQL Serverが稼働している
  • MySQL-develがインストール済み
  • perl-DBD-MySQLがインストール済み

さらにPostgreSQLにも対応している

  • PostgreSQL Serverが稼働している
  • PostgreSQL-develがインストール済み

./configure —with-pgsqlとする事でサポートされる

さらにはOracleDBにも対応している

DB関連もベンチする場合のインストール備忘録

# yum install mysql-server mysql-devel postgresql-server postgresql-devel
# vi /etc/my.cnf
[mysqld]
default-character-set=utf8 ←追加
old_passwords=0 ←変更
[mysql] ←追加
default-character-set=utf8 ←追加
 
# service mysqld start
# service postgresql start
# vi /var/lib/pgsql/data/pg_hba.conf
全てをコメントアウトしてから
local all all trust ←追加
host all all 127.0.0.1/32 trust ←追加
# vi /var/lib/pgsql/data/postgres.conf
listen_address ←コメント外す
port ←コメント外す
# service postgresql restart
 
# mysql
mysql> ←ログインできる事を確認
mysql> quit
# psql -U postgres
postgres=# ←ログインできる事を確認
postgres=# \q
 
# service cpuspeed stop

使い方

これが難解…

sysbench [common-options] --test=name [test-options] command

command
prepara テストを実行する前に必要な環境を作成する、–testがfileio、oltpの場合のみ
run 実行
cleanup 何かのテストが実行された際に作成された一時データの削除
help 基本的な使用方法表示
–test=name help 指定されたテストモードの使用方法表示
version バージョン表示
–test=
fileio ファイルIOテスト
cpu CPU性能テスト
memory メモリテスト
threads スレッド性能テスト
mutex Mutex性能テスト
oltp データベース性能テスト

使うだろうと思われるやつ

common-options デフォルト値
—num-threads=X threadsの数 1
—max-request=X リクエスト数 10000
—thread-stack-size スレッドのスタックサイズ 32K
service cpuspeed stopを忘れない事

CPU

# sysbench --test=cpu run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 1
 
Doing CPU performance benchmark
 
Threads started!
Done.
 
Maximum prime number checked in CPU test: 10000
 
 
Test execution summary:
    total time:                          18.0980s
    total number of events:              10000
    total time taken by event execution: 18.0936
    per-request statistics:
         min:                                  1.79ms
         avg:                                  1.81ms
         max:                                  2.88ms
         approx.  95 percentile:               1.85ms
 
Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   18.0936/0.00

OLTP

データベースベンチマークの場合、デフォルトでsbtestという名称のデータベースを利用するので事前に作成しておく必要がある

MySQLの場合

# mysql
mysql> create database sbtest;
mysql> \q
# sysbench --test=oltp --db-driver=mysql --mysql-user=STRINGS --mysql-password=STRINGS prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark
 
Creating table 'sbtest'...
Creating 10000 records in table 'sbtest'...
# sysbench --test=oltp --db-driver=mysql --mysql-user=STRINGS --mysql-password=STRINGS run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 1
 
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.
 
OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (431.16 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (8192.02 per sec.)
    other operations:                    20000  (862.32 per sec.)
 
Test execution summary:
    total time:                          23.1933s
    total number of events:              10000
    total time taken by event execution: 23.1183
    per-request statistics:
         min:                                  1.95ms
         avg:                                  2.31ms
         max:                                 60.73ms
         approx.  95 percentile:               2.46ms
 
Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   23.1183/0.00

PostgreSQLの場合

# createdb sbtest -U postgres
# sysbench --test=oltp --db-driver=pgsql --pgsql-user=STRINGS --pgsql-password=STRINGS prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark
 
Creating table 'sbtest'...
NOTICE:  CREATE TABLE will create implicit sequence "sbtest_id_seq" for serial column "sbtest.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "sbtest_pkey" for table "sbtest"
Creating 10000 records in table 'sbtest'...
# sysbench --test=oltp --db-driver=pgsql --pgsql-user=STRINGS --pgsql-password=STRINGS run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 1
 
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.
 
OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (233.45 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (4435.62 per sec.)
    other operations:                    20000  (466.91 per sec.)
 
Test execution summary:
    total time:                          42.8351s
    total number of events:              10000
    total time taken by event execution: 42.7622
    per-request statistics:
         min:                                  2.07ms
         avg:                                  4.28ms
         max:                                207.00ms
         approx.  95 percentile:               6.43ms
 
Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   42.7622/0.00

ちょっとはまった事

sysbenchでDB測定してたけど超遅い状態を検知した。

postgresqlの場合

fsync = off
または
synchronous_commint = off
を設定する
これはDiskIOの待ちが大きかったために、COMMITで待たされる結果、sysbenchの結果が激遅いになってやつ

mysqlの場合

InnoDBで作成したtableに対して実行すると激遅い
MyISAMはCPU依存速度が出る
InnoDBでもsimpleテストは激早い --oltp-test-mode=simple
トランザクション処理を行わないのがその理由
sysbenchのオプションでエンジンを指定できる
--mysql-table-engine={myisam,innodb}

グラフ(テスト中)

sysbenchを使った結果

This content requires JavaScript.