sysbench 개요
luajit 기반의 스크립트 형태의 멀티스레드 기반의 benchmark 프로그램이며 다음과 같은 특징이 있다.
- open source
- database benchmark
- mysql
- mariadb
- postgresql
- os benchmark
- cpu
- memory
- disk i/o
mysql 과 mariadb 등의 성능비교시에 많이 이용된다.
sysbench 설치하기
설치는 redhat 계열의 yum 이나 debian 계열의 apt 를 이용하여 설치할 수도 있으면 여기서는 github 을 통한 설치를 설명한다.
설치 프로그램을 이용한 간단설치
# ubuntu
shell> apt-get install sysbench
# redhat 계열
shell> yum -y install sysbench
sysbench 소스 다운로드
$ wget https://github.com/akopytov/sysbench/archive/master.zip
--2019-07-03 10:37:43-- https://github.com/akopytov/sysbench/archive/master.zip
Resolving github.com (github.com)... 52.78.231.108
Connecting to github.com (github.com)|52.78.231.108|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/akopytov/sysbench/zip/master [following]
--2019-07-03 10:37:44-- https://codeload.github.com/akopytov/sysbench/zip/master
Resolving codeload.github.com (codeload.github.com)... 192.30.255.120
Connecting to codeload.github.com (codeload.github.com)|192.30.255.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2282490 (2.2M) [application/zip]
Saving to: ‘master.zip’
100%[=======================================================================>] 2,282,490 1.89MB/s in 1.2s
2019-07-03 10:37:45 (1.89 MB/s) - ‘master.zip’ saved [2282490/2282490]
chlee@dev:~/tmp
$ unzip master.zip
Archive: master.zip
faaff4f52489d85c605a1071004734c89fcd42d2
creating: sysbench-master/
inflating: sysbench-master/.gitignore
inflating: sysbench-master/.travis.yml
inflating: sysbench-master/COPYING
inflating: sysbench-master/ChangeLog
inflating: sysbench-master/Makefile.am
inflating: sysbench-master/README.md
... ...
$ cd sysbench-master
dependency 패키지 설치하기
$ sudo yum -y install libtool mysql-devel automake lua
[sudo] chlee의 암호:
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.kaist.ac.kr
* extras: ftp.kaist.ac.kr
* updates: ftp.kaist.ac.kr
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Package libtool-2.4.2-22.el7_3.x86_64 already installed and latest version
Package automake-1.13.4-3.el7.noarch already installed and latest version
Package lua-5.1.4-15.el7.x86_64 already installed and latest version
Resolving Dependencies
컴파일 및 설치
$
$ ./autogen.sh
$ ./configure
$ make
$ make install
$ ./bin/sysbench --version
sysbench 1.1.0
mysql 의 header 파일 및 library 파일등을 참조 하는데 configure 스크립트에서 설치된 mysql 바이너를 통해서 설치된 mysql 을 찾게 된다.
별도의 mysql 을 설치했다면 오류없이 컴파일 가능하다.
sysbench 사용하기
database benchmark 를 하기 위해서 sysbench 는 3개의 단계로 사용할 수 있다.
- prepare
- 테이블 및 데이터 생성
- run
- 주어진 benchmark 테스트를 실제 수행
- cleanup
- 테이블 및 데이터 drop
cpu, memory 는 run 만으로도 수행할 수 있으며, disk 는 prepare 단계가 선행되어야 한다.
sysbench command line 구성하기
sysbench 를 이용해서 database 를 테스트 할때 입력해야하는 옵션이 많은 편이다.
$ sysbench <options> <op_type (prepare, run, cleanup)>
$ sysbench \
--histogram \
--mysql-host=$HOST \
--mysql-port=$PORT \
--mysql-user=$USER \
--mysql-password=$PASS \
--mysql-db=$DB \
--threads=$THREAD_CNT \
--table-size=$ROW_CNT \
--tables=$TABLE_CNT \
$LUA_PATH/oltp_read_write.lua \
$OP_TYPE"
options
mysql 을 테스트했을때를 기준으로 options 을 정리하면 다음과 같다.
optiondescription
--histogram | 테스틑된 결과의 latency 분포도를 출력한다. |
--mysql-host | mysql host ( localhost, 127.0.0.1 등 ) |
--mysql-port | mysql port ( default 3306 ) |
--mysql-user | mysql user |
--mysql-password | mysql user password |
--mysql-db | mysql database |
--threads | client thread count |
--table-size | 각 테이블의 row 갯수 |
--tables | 테스트에 사용될 table 의 갯수 |
lua 로 작성된 test 스크립트 경로 | |
$op_type | prepare , run, clean |
prepare
테이블을 생성하고 테스트에 필요한 데이터를 생성하는 단계이다.
sysbench --histogram --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=test --mysql-db=test --threads=1 --table-size=100 --tables=1 /home/chlee/local/share/sysbench/oltp_read_write.lua prepare
sysbench 1.1.0-faaff4f (using bundled LuaJIT 2.1.0-beta3)
Creating table 'sbtest1'...
Inserting 100 records into 'sbtest1'
Creating a secondary index on 'sbtest1'...
run
실제 benchmark 를 수행한다.
sysbench --histogram --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=test --mysql-db=test --threads=1 --table-size=100 --tables=1 /home/chlee/local/share/sysbench/oltp_read_write.lua run
sysbench 1.1.0-faaff4f (using bundled LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
Latency histogram (values are in milliseconds)
value ------------- distribution ------------- count
2.069 | 4
2.106 |* 10
2.145 |** 18
2.184 |***** 51
2.223 |******** 76
2.264 |********** 103
2.305 |**************** 158
2.347 |************************* 256
2.389 |******************************* 310
2.433 |************************************ 366
2.477 |**************************************** 405
2.522 |************************************* 378
2.568 |******************************** 322
2.615 |******************************** 321
2.662 |************************** 268
2.710 |******************* 190
2.760 |**************** 162
2.810 |************* 132
2.861 |********* 89
2.913 |****** 63
2.966 |**** 42
3.020 |*** 29
3.075 |* 11
3.130 |* 10
3.187 |** 16
3.245 |* 10
3.304 | 5
3.364 |* 6
3.425 | 1
3.488 | 5
3.551 | 1
3.615 | 3
3.681 | 2
3.748 | 5
3.816 | 2
3.885 | 1
3.956 | 2
4.028 | 2
4.176 | 2
4.252 | 2
4.329 | 1
4.407 | 2
4.487 | 4
4.569 | 3
4.652 | 2
4.737 | 1
4.823 | 1
5.090 | 2
5.183 | 1
5.277 | 1
5.470 | 1
5.671 | 2
5.774 | 1
5.879 | 3
5.986 | 1
6.790 | 1
6.913 | 1
7.565 | 1
8.130 | 1
9.560 | 1
16.115 | 1
18.280 | 1
SQL statistics:
queries performed:
read: 54208
write: 15488
other: 7744
total: 77440
transactions: 3872 (387.01 per sec.)
queries: 77440 (7740.13 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
Throughput:
events/s (eps): 387.0065
time elapsed: 10.0050s
total number of events: 3872
Latency (ms):
min: 2.08
avg: 2.58
max: 18.25
95th percentile: 2.91
sum: 9992.26
Threads fairness:
events (avg/stddev): 3872.0000/0.00
execution time (avg/stddev): 9.9923/0.00
cleanup
테스트에 사용된 데이터 및 테이블을 삭제 한다.
sysbench --histogram --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test --mysql-password=test --mysql-db=test --threads=1 --table-size=100 --tables=1 /home/chlee/local/share/sysbench/oltp_read_write.lua cleanup
sysbench 1.1.0-faaff4f (using bundled LuaJIT 2.1.0-beta3)
Dropping table 'sbtest1'...