안녕하세요. 스타트업하는 개발자 DevKwon 권선우입니다.
간단히 CPU, RAM, HDD(SSD)의 벤치마킹 하는 방법을 알아보겠습니다. 바로 sysbench 명령어를 이용하여 벤치마킹을 해보겠습니다.
SYSBENCH
sysbench 를 이용해보겠습니다.
CPU 벤치 방법
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=2 run
yum install sysbench
apt-get install sysbench
brew install sysbench
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 --max-requests=10000 --max-time=100 run
sean@localhost:~$ sysbench --test=cpu --cpu-max-prime=20000 --num-threads=2 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 2
Doing CPU performance benchmark
Threads started!
Done.
Maximum prime number checked in CPU test: 20000
Test execution summary:
total time: 15.3272s
total number of events: 10000
total time taken by event execution: 30.6441
per-request statistics:
min: 1.40ms
avg: 3.06ms
max: 27.11ms
approx. 95 percentile: 9.13ms
Threads fairness:
events (avg/stddev): 5000.0000/0.00
execution time (avg/stddev): 15.3221/0.00
잠시 기다려 보면 아래와 같은 결과 값이 나옵니다. total time 을 보시면 되고 15.32초가 걸렸습니다. 지금 서버는 cpu 2개인 서버인데, 만약 –num-thread 값을 1로 바꾸면 거의 두배인 30.6초 정도 나오게 되겠습니다.
맥북 프로에서는 8.3267s,, 스마일서브 1core (iwinv) 14.3366s, 2core : 7.3577s 정도 나왔습니다. CPU많으면 개수만큼 성능이 좋네요.
이런식으로 벤치 마킹을 하시면 됩니다.
RAM 성능 측정 방법은
sysbench --test=memory run
RAM 성능 측정하는 지표는 역시 실행시간입니다.
제 맥북 프로에서는 49.2817s, 스마일서브(iwinv) 호스팅 계정은 70.5834s, Azure 2Core instance 는 68.1875s 이였습니다.
102400.00 MiB transferred (2077.77 MiB/sec) 와 같이 초당 전송 속도를 보는 것도 측정방법의 한 방법이겠습니다.
이번엔 SSD(HDD포함) 측정을 해보겠습니다.
mkdir test cd test sysbench --test=fileio --file-total-size=1G prepare
sysbench --test=fileio --file-total-size=1G --file-test-mode=rndrw --max-time=60 --max-requests=0 run
sysbench --test=fileio --file-total-size=1G cleanup
먼저 test 디렉토리를 만들고, 거기에서 prepare 명령어로 준비 과정을 거칩니다. (벤치마킹 돌릴 파일 생성)
run 명령어로 벤치마킹을 합니다. 이제 잠시 기다리면 결과가 나옵니다. 이번에는 초당 입/출력 대역폭으로 벤치마크 결과를 판단해보겠습니다.
sean@localhost:~/test$ sysbench --test=fileio --file-total-size=1G --file-test-mode=rndrw --max-time=60 --max-requests=0 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Extra file open flags: 0
128 files, 8Mb each
1Gb 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: 29400 Read, 19600 Write, 62596 Other = 111596 Total
Read 459.38Mb Written 306.25Mb Total transferred 765.62Mb (12.76Mb/sec)
816.64 Requests/sec executed
Test execution summary:
total time: 60.0018s
total number of events: 49000
total time taken by event execution: 10.0451
per-request statistics:
min: 0.00ms
avg: 0.21ms
max: 23.24ms
approx. 95 percentile: 0.73ms
Threads fairness:
events (avg/stddev): 49000.0000/0.00
execution time (avg/stddev): 10.0451/0.00
file-total-size는 RAM 용량이상으로 이상으로 넉넉하게 잡아주시면 더 정확한 결과가 나올 수 있습니다. 저는 대략만 알면 되기에 1G 만 테스트 해보았습니다.
마지막으로 cleanup 명령어로 파일을 제거해 주시면 되겠습니다. rmdir test
로 디렉토리도 제거하시고요.
실행결과는 다음과 같습니다.
맥프로 SSD의 성능이 어마어마했는데요.
sysbench
이거 하나면 됩니다.