을 벤치마킹하는 방법.png)
Sysbench로 시스템(CPU, 파일 IO, MySQL)을 벤치마킹하는 방법
2022-10-19 last update
8 minutes reading linuxsysbench 는 집중적인 로드에서 데이터베이스를 실행할 계획인 경우 중요한 시스템 성능에 대한 인상을 빠르게 얻을 수 있는 벤치마크 제품군입니다. 이 문서에서는 sysbench를 사용하여 CPU, 파일 IO 및 MySQL 성능을 벤치마킹하는 방법을 설명합니다.
Debian/Ubuntu에서 sysbench는 다음과 같이 설치할 수 있습니다.
EPEL 저장소 추가:
보세요
이제 CPU 성능, 파일 IO 성능 및 MySQL 성능에 대해 자세히 알려주는 간단한 세 가지 기본 테스트를 수행하겠습니다.
다음과 같이 CPU 성능을 벤치마킹할 수 있습니다.
총 시간: 23.8724초
물론 이러한 수치의 가치를 알기 위해서는 여러 시스템의 벤치마크를 비교해야 합니다.
파일 IO 성능을 측정하려면 먼저 RAM보다 훨씬 더 큰 테스트 파일을 생성해야 합니다.
읽기 9.375Mb 쓰기 6.25Mb 총 전송 15.625Mb(53.316Kb/초)
벤치마크 후에 시스템에서 150GB 테스트 파일을 삭제할 수 있습니다.
MySQL 성능을 측정하기 위해 먼저 데이터베이스 테스트에서 1,000,000개의 데이터 행으로 테스트 테이블을 만듭니다.
그런 다음 MySQL 벤치마크를 다음과 같이 실행할 수 있습니다.
거래: 160990 (초당 2683.06)
나중에 시스템을 정리하려면(즉, 테스트 테이블 제거) 다음을 실행합니다.
시스템 벤치: http://sysbench.sourceforge.net/
1 시스템벤치 설치
Debian/Ubuntu에서 sysbench는 다음과 같이 설치할 수 있습니다.
sudo apt-get install sysbenchCentOS 및 Fedora에서는 EPEL 저장소에서 설치할 수 있습니다.
EPEL 저장소 추가:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release
yum -y update
그런 다음 yum으로 sysbench를 설치합니다.yum install sysbenchsysbench 옵션 개요 보기
보세요
man sysbench매개변수에 대해 자세히 알아보세요.
이제 CPU 성능, 파일 IO 성능 및 MySQL 성능에 대해 자세히 알려주는 간단한 세 가지 기본 테스트를 수행하겠습니다.
2 CPU 벤치마크
다음과 같이 CPU 성능을 벤치마킹할 수 있습니다.
sysbench --test=cpu --cpu-max-prime=20000 run
[email protected]:~# sysbench --test=cpu --cpu-max-prime=20000 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: 20000
Test execution summary:
total time: 23.8724s
total number of events: 10000
total time taken by event execution: 23.8716
per-request statistics:
min: 2.31ms
avg: 2.39ms
max: 6.39ms
approx. 95 percentile: 2.44ms
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 23.8716/0.00
[email protected]:~#
총 시간: 23.8724초
물론 이러한 수치의 가치를 알기 위해서는 여러 시스템의 벤치마크를 비교해야 합니다.
3 파일 IO 벤치마크
파일 IO 성능을 측정하려면 먼저 RAM보다 훨씬 더 큰 테스트 파일을 생성해야 합니다.
sysbench --test=fileio --file-total-size=150G prepare그런 다음 벤치마크를 실행할 수 있습니다.
sysbench --test=fileio --file-total-size=150G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run
[email protected]:~# sysbench --test=fileio --file-total-size=150G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run중요한 숫자는 Kb/sec 값입니다.
sysbench: /usr/lib/libmysqlclient.so.18: no version information available (required by sysbench)
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Initializing random number generator from timer.
Extra file open flags: 0
128 files, 1.1719Gb each
150Gb total file size
Block size 16Kb
Number of random requests for random IO: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Threads started!
Time limit exceeded, exiting...
Done.
Operations performed: 600 Read, 400 Write, 1186 Other = 2186 Total
Read 9.375Mb Written 6.25Mb Total transferred 15.625Mb (53.316Kb/sec)
3.33 Requests/sec executed
Test execution summary:
total time: 300.0975s
total number of events: 1000
total time taken by event execution: 158.7611
per-request statistics:
min: 0.01ms
avg: 158.76ms
max: 2596.96ms
approx. 95 percentile: 482.29ms
Threads fairness:
events (avg/stddev): 1000.0000/0.00
execution time (avg/stddev): 158.7611/0.00
[email protected]:~#
읽기 9.375Mb 쓰기 6.25Mb 총 전송 15.625Mb(53.316Kb/초)
벤치마크 후에 시스템에서 150GB 테스트 파일을 삭제할 수 있습니다.
sysbench --test=fileio --file-total-size=150G cleanup
4 MySQL 벤치마크
MySQL 성능을 측정하기 위해 먼저 데이터베이스 테스트에서 1,000,000개의 데이터 행으로 테스트 테이블을 만듭니다.
sysbench --test=oltp --oltp-table-size=1000000 --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword prepare
[email protected]:~# sysbench --test=oltp --oltp-table-size=1000000 --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword prepare
sysbench 0.4.12: multi-threaded system evaluation benchmark
No DB drivers specified, using mysql위 명령어에서 yourrootsqlpassword라는 단어를 MySQL 루트 비밀번호로 바꿉니다. 다음 명령에서도 동일하게 수행하십시오.
Creating table 'sbtest'...
Creating 1000000 records in table 'sbtest'...
[email protected]:~#
그런 다음 MySQL 벤치마크를 다음과 같이 실행할 수 있습니다.
sysbench --test=oltp --oltp-table-size=1000000 --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword --max-time=60 --oltp-read-only=on --max-requests=0 --num-threads=8 run
[email protected]:~# sysbench --test=oltp --oltp-table-size=1000000 --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword --max-time=60 --oltp-read-only=on --max-requests=0 --num-threads=8 run중요한 숫자는 초당 트랜잭션 값입니다.
sysbench 0.4.12: multi-threaded system evaluation benchmark
No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 8
Doing OLTP test.
Running mixed OLTP test
Doing read-only 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
Threads started!
Time limit exceeded, exiting...
(last message repeated 7 times)
Done.
OLTP test statistics:
queries performed:
read: 2253860
write: 0
other: 321980
total: 2575840
transactions: 160990 (2683.06 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 2253860 (37562.81 per sec.)
other operations: 321980 (5366.12 per sec.)
Test execution summary:
total time: 60.0024s
total number of events: 160990
total time taken by event execution: 479.3419
per-request statistics:
min: 0.81ms
avg: 2.98ms
max: 3283.40ms
approx. 95 percentile: 4.62ms
Threads fairness:
events (avg/stddev): 20123.7500/63.52
execution time (avg/stddev): 59.9177/0.00
[email protected]:~#
거래: 160990 (초당 2683.06)
나중에 시스템을 정리하려면(즉, 테스트 테이블 제거) 다음을 실행합니다.
sysbench --test=oltp --db-driver=mysql --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword cleanup