리눅스 서버 벤치마크 프로그램 sysbench 사용 방법

리눅스를 서버로 사용하는 경우 대부분 CUI 환경에서 실행되기 때문에 윈도우 같은 다양한 방식의 벤치마크는 어렵지만 sysbench로 CPU, RAM, Disk i/o 리소스를 간단하게 벤치마크 할 수 있습니다.

특히 VPS를 사용하는 경우 업체에서 하드웨어 사양을 정확하게 명시하지는 않기 때문에 성능을 비교하는 데이터로도 활용할 수 있습니다.

sysbench 설치

우분투
apt-get install sysbench
CentOS
yum install sysbench

sysbench 사용법

CPU 테스트

sysbench --test=cpu --cpu-max-prime=100000 --num-threads=1 run

--num-threads 값은 CPU 코어 수에 맞춰 입력하고 만일 하이퍼 스레드가 적용되어 있다면 x2를 하면 되겠습니다. 만일 비슷한 사양의 CPU를 비교한다면 --cpu-max-prime 수치를 높여 테스트 하면 좀더 부하를 높일 수 있습니다.

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time

Prime numbers limit: 100000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:    33.07

General statistics:
    total time:                          10.0079s
    total number of events:              331

Latency (ms):
         min:                                 29.02
         avg:                                 30.22
         max:                                 35.97
         95th percentile:                     31.37
         sum:                              10003.15

Threads fairness:
    events (avg/stddev):           331.0000/0.00
    execution time (avg/stddev):   10.0032/0.00

결과값은 위와 같이 확인할 수 있으며 연산 시간이기 때문에 초가 낮을 수록 빠른 CPU 입니다.

--cpu-max-prime 옵션값을 높게 입력했을때 비정상적으로 출력이 늦다면 ulimit open files 값을 올린 다음 테스트 하시면 됩니다.

RAM(메모리) 테스트

sysbench --test=memory run

램 벤치마크 명령어 읽기와 쓰기로 나뉘는데 메모리 테스트의 기본값이 쓰기이므로 쓰기 테스트는 위와 같이 간단하게 실행할 수 있습니다.

sysbench --test=memory --memory-oper=read run

만일 읽기 속도를 테스트 하고 싶다면 --memory-oper=read 옵션을 붙여서 실행하면 됩니다.

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time

Running memory speed test with the following options:
  block size: 1KiB
  total size: 102400MiB
  operation: write
  scope: global

Initializing worker threads...

Threads started!

Total operations: 31676656 (3166664.62 per second)

30934.23 MiB transferred (3092.45 MiB/sec)


General statistics:
    total time:                          10.0004s
    total number of events:              31676656

Latency (ms):
         min:                                  0.00
         avg:                                  0.00
         max:                                  6.77
         95th percentile:                      0.00
         sum:                               4375.63

Threads fairness:
    events (avg/stddev):           31676656.0000/0.00
    execution time (avg/stddev):   4.3756/0.00

램 테스트는 초당 전송량이므로 수치가 높을수록 좋습니다.

디스크 I/O 테스트

sysbench --test=fileio --file-total-size=10G prepare

위 명령어로 테스트에 필요한 파일을 생성합니다. 리눅스는 기본적으로 디스크 캐시가 정용되어 있기 때문에 현재 장착된 RAM 크기보다 큰 값을 옵션으로 넣어야 합니다.

128 files, 81920Kb each, 10240Mb total
Creating files for the test...
Extra file open flags: 0
Creating file test_file.0
.
.
.
Creating file test_file.127
10737418240 bytes written in 35.52 seconds (288.30 MiB/sec).

지정한 파일 크기를 128개로 나눠 생성하며 마지막 라인에 초당 생성한 파일 용량이 표시됩니다.

sysbench --test=fileio --file-test-mode=rndrw --max-time=60 --max-requests=0 run

예로 위 명령어는 10G 파일을 생성한 다음 생성한 파일을 대상으로 랜덤 읽기,쓰기 테스트를 60초 동안 진행합니다.

File operations:
    reads/s:                      1984.16
    writes/s:                     1322.77
    fsyncs/s:                     4231.85

Throughput:
    read, MiB/s:                  31.00
    written, MiB/s:               20.67

General statistics:
    total time:                          60.0043s
    total number of events:              452400

Latency (ms):
         min:                                  0.00
         avg:                                  0.13
         max:                                 18.74
         95th percentile:                      0.39
         sum:                              59584.89

Threads fairness:
    events (avg/stddev):           452400.0000/0.00
    execution time (avg/stddev):   59.5849/0.00

위와 같이 Reads, Writes 속도를 측정할 수 있으며 4K 엑세스 속도에 중요한 레이턴시도 참고할 수 있습니다. 초당 MiB가 클수록 빠른 처리량을 보이기 때문에 높을 수록 좋습니다.

위 명령어는 랜덤 읽기, 쓰기를 예로 들었는데 --file-test-mode 옵션은 다음과 같은 테스트를 지원합니다.

옵션동작
seqrd순차 읽기
seqwr순차 쓰기
seqrw순차 읽기/쓰기
rndrd랜덤 읽기
rndwr랜덤 쓰기
rndrw랜덤 읽기/쓰기
sysbench --test=fileio cleanup

디스크 속도 벤치마크가 끝나면 cleanup 옵션으로 파일을 삭제해 정리하면 되겠습니다.

Leave a Comment