• 리눅스 디스크 속도 측정, 리눅스 cpu 속도 확인, 리눅스 메모리 속도 측정에 사용될 수 있는 명령어
  • sysbench 명령어는 인텐시브한 로드에서 데이터베이스를 운영해야하는 시스템에 필요한 운영체제를 평가하는 모듈화된 크로스 플랫폼 멀티 쓰레드 벤치마크 도구
  • 데이터베이스를 설치하지 않고도 복잡한 세팅없이 시스템 성능을 분석 가능
  • VPS(virtual private server)를 사용하는 경우 업체에서 하드웨어 사양을 정확하게 명시하지는 않기 때문에 성능을 비교하는 데이터로도 활용 가능


sysbench 제공 기능

  • 파일 입출력 성능
  • 스케쥴러 성능
  • 메모리 할당 및 전달 속도
  • POSIX 쓰레드 구현 성능
  • 데이터베이스 서버 성능


sysbench 설치

$ yum install -y sysbench



sysbench 명령어 3가지 부분

  • 명령어 구분
    1. prepare → 테스트 데이터를 생성하는 과정
    2. run → 실제 테스트를 실행 (oltp-read-write, oltp-read-only 등)
    3. cleanup → 테스트 데이터를 삭제하는 과정


성능테스트 실행

  • "준비 -> 실행 -> 삭제" 순서로 진행


컴파일된 테스트 속성

  1. fileio → 파일 I/O 테스트
  2. cpu → CPU 성능 테스트
  3. memory→ 메모리 기능 속도 테스트
  4. threads→ 스레드 하위 시스템 성능 테스트
  5. mutex → 뮤텍스 성능 테스트


sysbench 명령어 테스트

1. CPU 테스트 → total time이 낮을 수록 좋음

  • 소수 생성을 100000개 하여 cpu 테스트(기본적)

    $ sysbench --test=cpu --cpu-max-prime=100000 run
    WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
    sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
    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:    42.93
    
    General statistics:
      total time:                          10.0109s
      total number of events:              430
    
    Latency (ms):
           min:                                   22.98
           avg:                                   23.28
           max:                                   65.15
           95th percentile:                       23.10
           sum:                                10010.21
    
    Threads fairness:
      events (avg/stddev):           430.0000/0.00
      execution time (avg/stddev):   10.0102/0.00

  • CPU 코어 수에 맞춰 cpu 테스트 → 하이퍼 스레드를 적용하고 있다면 코어 수에 x2를 하여 --cpu-max-prime 값을 적용

    # CPU 코어 확인
    $ lscpu  | grep -i "^CPU(s)"
    CPU(s):                40
    
    # CPU 코어 40개 활용하여 테스트
    $ sysbench --test=cpu --cpu-max-prime=100000 --num-threads=40 run
    WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
    WARNING: --num-threads is deprecated, use --threads instead
    sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
    Running the test with following options:
    Number of threads: 40
    Initializing random number generator from current time
    
    Prime numbers limit: 100000
    
    Initializing worker threads...
    
    Threads started!
    
    CPU speed:
      events per second:  1256.42
    
    General statistics:
      total time:                          10.0281s
      total number of events:              12602
    
    Latency (ms):
           min:                                   27.73
           avg:                                   31.75
           max:                                   75.39
           95th percentile:                       31.37
           sum:                               400126.02
    
    Threads fairness:
      events (avg/stddev):           315.0500/2.31
      execution time (avg/stddev):   10.0032/0.02



2. Memory 테스트 → Read + Write = total이 높을 수록 좋음

  • 현재 설정된 메모리 기본값 검사 → 메모리 테스트의 기본값은 쓰기이므로 쓰기 테스트 값이 나옴

    $ sysbench --test=memory run
    WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
    sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
    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: 46492508 (4646316.29 per second)
    
    45402.84 MiB transferred (4537.42 MiB/sec)
    
    General statistics:
      total time:                          10.0002s
      total number of events:              46492508
    
    Latency (ms):
           min:                                    0.00
           avg:                                    0.00
           max:                                    0.02
           95th percentile:                        0.00
           sum:                                 4387.09
    
    Threads fairness:
      events (avg/stddev):           46492508.0000/0.00
      execution time (avg/stddev):   4.3871/0.00

  • 메모리 write 테스트(설정 有)

    1. memory block size는 1K

    2. 전역 메모리 사용

    3. 메모리 전체 사이즈는 128G

    4. write 테스트

      $ sysbench --test=memory --memory-block-size=1K --memory-scope=global --memory-total-size=128G --memory-oper=write run
      WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
      sysbench 1.0.17 (using system LuaJIT 2.0.4)
      
      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: 131072MiB
      operation: write
      scope: global
      
      Initializing worker threads...
      
      Threads started!
      
      Total operations: 46494366 (4646521.96 per second)
      
      45404.65 MiB transferred (4537.62 MiB/sec)
      
      General statistics:
      total time:                          10.0002s
      total number of events:              46494366
      
      Latency (ms):
       min:                                    0.00
       avg:                                    0.00
       max:                                    0.10
       95th percentile:                        0.00
       sum:                                 4385.85
      
      Threads fairness:
      events (avg/stddev):           46494366.0000/0.00
      execution time (avg/stddev):   4.3859/0.00

  • 메모리 write 테스트(설정 有)

    1. memory block size는 1K

    2. 전역 메모리 사용

    3. 메모리 전체 사이즈는 128G

    4. read 테스트

      $ sysbench --test=memory --memory-block-size=1K --memory-scope=global --memory-total-size=128G --memory-oper=read run
      WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
      sysbench 1.0.17 (using system LuaJIT 2.0.4)
      
      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: 131072MiB
      operation: read
      scope: global
      
      Initializing worker threads...
      
      Threads started!
      
      Total operations: 58485027 (5844890.88 per second)
      
      57114.28 MiB transferred (5707.90 MiB/sec)
      
      General statistics:
      total time:                          10.0002s
      total number of events:              58485027
      
      Latency (ms):
       min:                                    0.00
       avg:                                    0.00
       max:                                    0.09
       95th percentile:                        0.00
       sum:                                 2841.56
      
      Threads fairness:
      events (avg/stddev):           58485027.0000/0.00
      execution time (avg/stddev):   2.8416/0.00



3. Disk 테스트 → 결과 값이 높을 수록 좋음

  • 리눅스는 기본적으로 Disk 캐시가 정용되어 있기 때문에 현재 장착된 RAM 크기보다 큰 값을 옵션으로 넣어야 함
  • 리눅스 Disk 속도를 측정하기 위해서는 테스트 파일을 준비
  • 테스트 파일을 Disk에 저장하고 테스트를 진행
  • 테스트용 더미 파일을 준비 → 전체 용량이 350G 파일을 준비

    1. 지정한 파일 크기를 128개로 나눠 생성

    2. 마지막 라인에 초당 생성한 파일 용량이 표시

      $ sysbench --test=fileio --file-total-size=350G prepare
      WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
      sysbench 1.0.17 (using system LuaJIT 2.0.4)
      
      128 files, 2867200Kb each, 358400Mb total
      Creating files for the test...
      Extra file open flags: (none)
      Creating file test_file.0
      Creating file test_file.1
      Creating file test_file.2
      Creating file test_file.3
      Creating file test_file.4
      [...중략...]
      Creating file test_file.124
      Creating file test_file.125
      Creating file test_file.126
      Creating file test_file.127
      375809638400 bytes written in 2320.59 seconds (154.44 MiB/sec).
      
      # test_file.* 이름으로 파일이 생성 (2.8G 파일이 총 128개 생성)
      $ ls -alh test_file.*
      -rw------- 1 root root 2.8G Oct 13 11:07 test_file.0
      -rw------- 1 root root 2.8G Oct 13 11:07 test_file.1
      -rw------- 1 root root 2.8G Oct 13 11:09 test_file.10
      -rw------- 1 root root 2.8G Oct 13 11:38 test_file.100
      -rw------- 1 root root 2.8G Oct 13 11:38 test_file.101
      [...생략...]

  • 60초동안 순차 읽기 I/O (seqrd) → 테스트용 더미 파일에 문제가 있으면 다시 생성하여 테스트 필요

     $ sysbench --test=fileio --file-test-mode=seqrd --max-time=60 --file-total-size=350G run
     WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
     WARNING: --max-time is deprecated, use --time instead
     sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
     Running the test with following options:
     Number of threads: 1
     Initializing random number generator from current time
    
     Extra file open flags: (none)
     128 files, 2.7344GiB each
     350GiB total file size
     Block size 16KiB
     Periodic FSYNC enabled, calling fsync() each 100 requests.
     Calling fsync() at the end of test, Enabled.
     Using synchronous I/O mode
     Doing sequential read test
     Initializing worker threads...
    
     Threads started!
    
     File operations:
         reads/s:                      8942.74
         writes/s:                     0.00
         fsyncs/s:                     0.00
    
     Throughput:
         read, MiB/s:                  139.73
         written, MiB/s:               0.00
    
     General statistics:
         total time:                          60.0005s
         total number of events:              536615
    
     Latency (ms):
              min:                                    0.00
              avg:                                    0.11
              max:                                  160.53
              95th percentile:                        0.57
              sum:                                59796.43
    
     Threads fairness:
         events (avg/stddev):           536615.0000/0.00
         execution time (avg/stddev):   59.7964/0.00

  • 60초동안 순차 쓰기 I/O (seqwr)

     $ sysbench --test=fileio --file-test-mode=seqwr --max-time=60 --file-total-size=350G run
     WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
     WARNING: --max-time is deprecated, use --time instead
     sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
     Running the test with following options:
     Number of threads: 1
     Initializing random number generator from current time
    
     Extra file open flags: (none)
     128 files, 2.7344GiB each
     350GiB total file size
     Block size 16KiB
     Periodic FSYNC enabled, calling fsync() each 100 requests.
     Calling fsync() at the end of test, Enabled.
     Using synchronous I/O mode
     Doing sequential write (creation) test
     Initializing worker threads...
    
     Threads started!
    
     File operations:
         reads/s:                      0.00
         writes/s:                     13674.29
         fsyncs/s:                     17503.17
    
     Throughput:
         read, MiB/s:                  0.00
         written, MiB/s:               213.66
    
     General statistics:
         total time:                          60.0047s
         total number of events:              1870845
    
     Latency (ms):
              min:                                    0.00
              avg:                                    0.03
              max:                                  172.79
              95th percentile:                        0.03
              sum:                                59169.98
    
     Threads fairness:
         events (avg/stddev):           1870845.0000/0.00
         execution time (avg/stddev):   59.1700/0.00

  • 60초동안 순차 다시 쓰기 I/O (seqrewr)

     $ sysbench --test=fileio --file-test-mode=seqrewr --max-time=60 --file-total-size=350G run
     WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
     WARNING: --max-time is deprecated, use --time instead
     sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
     Running the test with following options:
     Number of threads: 1
     Initializing random number generator from current time
    
     Extra file open flags: (none)
     128 files, 2.7344GiB each
     350GiB total file size
     Block size 16KiB
     Periodic FSYNC enabled, calling fsync() each 100 requests.
     Calling fsync() at the end of test, Enabled.
     Using synchronous I/O mode
     Doing sequential rewrite test
     Initializing worker threads...
    
     Threads started!
    
     File operations:
         reads/s:                      0.00
         writes/s:                     13543.70
         fsyncs/s:                     17337.94
    
     Throughput:
         read, MiB/s:                  0.00
         written, MiB/s:               211.62
    
     General statistics:
         total time:                          60.0008s
         total number of events:              1852962
    
     Latency (ms):
              min:                                    0.00
              avg:                                    0.03
              max:                                   38.39
              95th percentile:                        0.02
              sum:                                59021.35
    
     Threads fairness:
         events (avg/stddev):           1852962.0000/0.00
         execution time (avg/stddev):   59.0214/0.00

  • 60초동안 랜덤 읽기 I/O (rndrd) → 테스트용 더미 파일에 문제가 있으면 다시 생성하여 테스트 필요

     $ sysbench --test=fileio --file-test-mode=rndrd --max-time=60 --file-total-size=350G run
     WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
     WARNING: --max-time is deprecated, use --time instead
     sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
     Running the test with following options:
     Number of threads: 1
     Initializing random number generator from current time
    
     Extra file open flags: (none)
     128 files, 2.7344GiB each
     350GiB total file size
     Block size 16KiB
     Number of IO requests: 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 read test
     Initializing worker threads...
    
     Threads started!
    
     File operations:
         reads/s:                      287.78
         writes/s:                     0.00
         fsyncs/s:                     0.00
    
     Throughput:
         read, MiB/s:                  4.50
         written, MiB/s:               0.00
    
     General statistics:
         total time:                          60.0024s
         total number of events:              17269
    
     Latency (ms):
              min:                                    0.01
              avg:                                    3.47
              max:                                  373.61
              95th percentile:                        7.84
              sum:                                59957.77
    
     Threads fairness:
         events (avg/stddev):           17269.0000/0.00
         execution time (avg/stddev):   59.9578/0.00

  • 60초동안 랜덤 쓰기 I/O (rndwr)

     $ sysbench --test=fileio --file-test-mode=rndwr --max-time=60 --file-total-size=350G run
     WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
     WARNING: --max-time is deprecated, use --time instead
     sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
     Running the test with following options:
     Number of threads: 1
     Initializing random number generator from current time
    
     Extra file open flags: (none)
     128 files, 2.7344GiB each
     350GiB total file size
     Block size 16KiB
     Number of IO requests: 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 write test
     Initializing worker threads...
    
     Threads started!
    
     File operations:
         reads/s:                      0.00
         writes/s:                     716.43
         fsyncs/s:                     918.96
    
     Throughput:
         read, MiB/s:                  0.00
         written, MiB/s:               11.19
    
     General statistics:
         total time:                          60.0145s
         total number of events:              98028
    
     Latency (ms):
              min:                                    0.00
              avg:                                    0.61
              max:                                  222.50
              95th percentile:                        4.10
              sum:                                59924.15
    
     Threads fairness:
         events (avg/stddev):           98028.0000/0.00
         execution time (avg/stddev):   59.9242/0.00

  • 60초동안 랜덤 읽기/쓰기 I/O (rndrw) → 테스트용 더미 파일에 문제가 있으면 다시 생성하여 테스트 필요

     $ sysbench --test=fileio --file-test-mode=rndrw --max-time=60 --file-total-size=350G run
     WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
     WARNING: --max-time is deprecated, use --time instead
     sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
     Running the test with following options:
     Number of threads: 1
     Initializing random number generator from current time
    
     Extra file open flags: (none)
     128 files, 2.7344GiB each
     350GiB total file size
     Block size 16KiB
     Number of IO requests: 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
     Initializing worker threads...
    
     Threads started!
    
     File operations:
         reads/s:                      276.83
         writes/s:                     184.55
         fsyncs/s:                     590.81
    
     Throughput:
         read, MiB/s:                  4.33
         written, MiB/s:               2.88
    
     General statistics:
         total time:                          60.0062s
         total number of events:              63016
    
     Latency (ms):
              min:                                    0.00
              avg:                                    0.95
              max:                                  193.77
              95th percentile:                        6.43
              sum:                                59925.04
    
     Threads fairness:
         events (avg/stddev):           63016.0000/0.00
         execution time (avg/stddev):   59.9250/0.00

  • 디스크 속도 벤치마크가 끝나면 cleanup 옵션으로 파일을 삭제해 정리

     $ sysbench --test=fileio cleanup
     WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
     sysbench 1.0.17 (using system LuaJIT 2.0.4)
    
     Removing test files...

+ Recent posts