User Tools

Site Tools


benchmarking

This is an old revision of the document!


Benchmarking

Benchmark website

Benchmark with ab tool

Syntax and basic options

  • Syntax:
    ab [options] [http[s]://]hostname[:port]/path
  • Basic options:
    • -n requests Number of requests to perform
    • -c concurrency Number of multiple requests to make

examples

  • run benchmark website shop.babies.vn with 250 requests and 15 concurrency multiple requests:
    ab -n 250 -c 15 http://shop.babies.vn/

    output:

    Benchmarking shop.babies.vn (be patient)
    Completed 100 requests
    Completed 200 requests
    Finished 250 requests
    
    
    Server Software:        Apache/2.2.27
    Server Hostname:        shop.babies.vn
    Server Port:            80
    
    Document Path:          /
    Document Length:        84625 bytes
    
    Concurrency Level:      15
    Time taken for tests:   161.918 seconds
    Complete requests:      250
    Failed requests:        249
       (Connect: 0, Receive: 0, Length: 249, Exceptions: 0)
    Write errors:           0
    Non-2xx responses:      129
    Total transferred:      2905559 bytes
    HTML transferred:       2842359 bytes
    Requests per second:    1.54 [#/sec] (mean)
    Time per request:       9715.107 [ms] (mean)
    Time per request:       647.674 [ms] (mean, across all concurrent requests)
    Transfer rate:          17.52 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    1   3.2      0      15
    Processing:   570 9706 8023.6   9803   26823
    Waiting:        0 4048 6813.2    816   26179
    Total:        570 9707 8023.3   9803   26823
    
    Percentage of the requests served within a certain time (ms)
      50%   9803
      66%  14587
      75%  16724
      80%  18510
      90%  20675
      95%  22680
      98%  24940
      99%  25740
     100%  26823 (longest request)

Benchmark with sysbench(CPU, File IO, MySQL)

Download and Install

Download:

wget http://downloads.mysql.com/source/sysbench-0.4.12.5.tar.gz

Install:

yum install libtool
cd sysbench
./autogen.sh
./configure
make & make install

Syntax and Basic Options

  • Syntax:
    sysbench [general-options]... --test=<test-name> [test-options]... command
  • Basic Options:

CPU Benchmark

run script below:

sysbench --test=cpu --cpu-max-prime=20000 run

output:

Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored


Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 20000


Test execution summary:
    total time:                          38.5596s
    total number of events:              10000
    total time taken by event execution: 38.5538
    per-request statistics:
         min:                                  3.69ms
         avg:                                  3.86ms
         max:                                 23.75ms
         approx.  95 percentile:               4.44ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   38.5538/0.00

And You see a lot of numbers, the most important of it is the total time:

total time:                          38.5596s

Of course, you must compare benchmarks across multiple systems to know what these numbers are worth.

File IO Benchmark

  1. Step1: Prepare:
    sysbench --test=fileio --file-total-size=5G prepare
  2. Step2: Run benchmark
    sysbench --test=fileio --file-total-size=5G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run

    output:

    sysbench 0.4.12.5:  multi-threaded system evaluation benchmark
    
    128 files, 40960Kb each, 5120Mb total
    Creating files for the test...
    [root@mail ~]# sysbench --test=fileio --file-total-size=5G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run
    sysbench 0.4.12.5:  multi-threaded system evaluation benchmark
    
    Running the test with following options:
    Number of threads: 1
    Initializing random number generator from timer.
    
    Random number generator seed is 0 and will be ignored
    
    
    Extra file open flags: 0
    128 files, 40Mb each
    5Gb 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:  243263 Read, 162175 Write, 518912 Other = 924350 Total
    Read 3.7119Gb  Written 2.4746Gb  Total transferred 6.1865Gb  (21.116Mb/sec)
     1351.45 Requests/sec executed
    
    Test execution summary:
        total time:                          300.0014s
        total number of events:              405438
        total time taken by event execution: 175.2639
        per-request statistics:
             min:                                  0.01ms
             avg:                                  0.43ms
             max:                                 22.63ms
             approx.  95 percentile:               1.02ms
    
    Threads fairness:
        events (avg/stddev):           405438.0000/0.00
        execution time (avg/stddev):   175.2639/0.00

    The important number is the Mb/sec value:

    Read 3.7119Gb  Written 2.4746Gb  Total transferred 6.1865Gb  (21.116Mb/sec)
  3. Step3: Cleanup
    sysbench --test=fileio --file-total-size=5G cleanup

MySQL Server Benchmark

  1. Step1: To measure MySQL performance, we first create a test table in the database test with 1,000,000 rows of data:
    sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword prepare
  2. Step2: Afterwards, you can run the MySQL benchmark as follows:
    sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword --max-time=60 --oltp-read-only=on --max-requests=0 --num-threads=8 run
  3. Step3: To clean up the system afterwards (i.e., remove the test table), run:
    sysbench --test=oltp --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword cleanup
benchmarking.1411195788.txt.gz · Last modified: 2022/10/29 16:15 (external edit)