User Tools

Site Tools


benchmarking

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
benchmarking [2014/09/20 02:39] – created adminbenchmarking [2022/10/29 16:15] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Benchmarking ====== ====== Benchmarking ======
 +===== Benchmark website =====
 +==== Benchmark with ab tool ====
 +ab tool will be installed when we install webserver apache
 +=== Syntax and basic options ===
 +  * Syntax:<code bash>
 +ab [options] [http[s]://]hostname[:port]/path
 +</code>
 +  * 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 100 requests and 4 concurrency multiple requests:<code bash>
 +ab -n 100 -c 4 http://shop.babies.vn/
 +</code>output:<code>
 +This is ApacheBench, Version 2.3 <$Revision: 655654 $>
 +Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
 +Licensed to The Apache Software Foundation, http://www.apache.org/
 +
 +Benchmarking shop.babies.vn (be patient).....done
 +
 +
 +Server Software:        Apache/2.2.27
 +Server Hostname:        shop.babies.vn
 +Server Port:            80
 +
 +Document Path:          /
 +Document Length:        81923 bytes
 +
 +Concurrency Level:      4
 +Time taken for tests:   61.233 seconds
 +Complete requests:      100
 +Failed requests:        99
 +   (Connect: 0, Receive: 0, Length: 99, Exceptions: 0)
 +Write errors:           0
 +Non-2xx responses:      5
 +Total transferred:      7973422 bytes
 +HTML transferred:       7921109 bytes
 +Requests per second:    1.63 [#/sec] (mean)
 +Time per request:       2449.332 [ms] (mean)
 +Time per request:       612.333 [ms] (mean, across all concurrent requests)
 +Transfer rate:          127.16 [Kbytes/sec] received
 +
 +Connection Times (ms)
 +              min  mean[+/-sd] median   max
 +Connect:        0    0   1.3      0      11
 +Processing:   266 2430 429.9   2397    3861
 +Waiting:      265 2313 428.4   2273    3860
 +Total:        266 2430 429.8   2397    3861
 +
 +Percentage of the requests served within a certain time (ms)
 +  50%   2397
 +  66%   2485
 +  75%   2639
 +  80%   2664
 +  90%   2925
 +  95%   3002
 +  98%   3834
 +  99%   3861
 + 100%   3861 (longest request)
 +</code>
 +===== Benchmark with sysbench(CPU, File IO, MySQL) =====
 +==== Download and Install ====
 +Download:<code bash>
 +wget http://downloads.mysql.com/source/sysbench-0.4.12.5.tar.gz
 +</code>
 +Install:<code bash>
 +yum install libtool
 +cd sysbench
 +./autogen.sh
 +./configure
 +make & make install
 +</code>
 +==== Syntax and Basic Options ====
 +  * Syntax:<code bash>
 +sysbench [general-options]... --test=<test-name> [test-options]... command
 +</code>
 +  * Basic Options:
 +==== CPU Benchmark ====
 +run script below:<code bash>
 +sysbench --test=cpu --cpu-max-prime=20000 run
 +</code>output:<code>
 +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
 +</code>And You see a lot of numbers, the most important of it is the total time:<code>
 +total time:                          38.5596s
 +</code>Of course, you must compare benchmarks across multiple systems to know what these numbers are worth.
 +==== File IO Benchmark ====
 +  - Step1: Prepare:<code bash>
 +sysbench --test=fileio --file-total-size=5G prepare
 +</code>
 +  - Step2: Run benchmark<code bash>
 +sysbench --test=fileio --file-total-size=5G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run
 +</code>output:<code>
 +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:  701100 Read, 467400 Write, 1495579 Other = 2664079 Total
 +Read 10.698Gb  Written 7.132Gb  Total transferred 17.83Gb  (60.859Mb/sec)
 + 3894.99 Requests/sec executed
 +
 +Test execution summary:
 +    total time:                          300.0011s
 +    total number of events:              1168500
 +    total time taken by event execution: 134.9176
 +    per-request statistics:
 +         min:                                  0.00ms
 +         avg:                                  0.12ms
 +         max:                                 14.60ms
 +         approx.  95 percentile:               0.28ms
 +
 +Threads fairness:
 +    events (avg/stddev):           1168500.0000/0.00
 +    execution time (avg/stddev):   134.9176/0.00
 +</code>The important number is the Mb/sec value:<code>
 +Read 10.698Gb  Written 7.132Gb  Total transferred 17.83Gb  (60.859Mb/sec)
 +</code>
 +  - Step3: Cleanup<code bash>
 +sysbench --test=fileio --file-total-size=5G cleanup
 +</code>
 +==== MySQL Server Benchmark ====
 +  - Step1: To measure MySQL performance, we first create a test table in the database test with 1,000,000 rows of data:<code bash>
 +sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword prepare
 +</code>
 +  - Step2: Afterwards, you can run the MySQL benchmark as follows:<code bash>
 +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
 +</code>
 +  - Step3: To clean up the system afterwards (i.e., remove the test table), run:<code bash>
 +sysbench --test=oltp --mysql-db=test --mysql-user=root --mysql-password=yourrootsqlpassword cleanup
 +</code>
 +===== Benchmark with graphing software =====
 +==== Better Cacti Templates ====
 +Download: wget https://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz
 +===== Benchmark network speed =====
 +==== using speedtest ====
 +  - Step1: install speedtest on linux:<code bash>
 +pip install speedtest-cli
 +</code>
 +  - Step2: Run test<code bash>
 +speedtest
 +</code>
 +==== network monitor with iptraf ====
 +refer: http://www.tecmint.com/real-time-interactive-ip-lan-monitoring-with-iptraf-tool/
 +  * Install <code bash>
 +yum install iptraf
 +</code>
 +  * Run normal<code bash>
 +iptraf
 +</code>
 +  * Monitor Traffic on eth0:<code bash>
 +iptraf -s eth0
 +</code>
 +===== Benchmark File System Read Write Performance =====
 +refer: http://www.slashroot.in/linux-file-system-read-write-performance-test
 +==== Using dd command ====
 +  * Benchmarck the speed with which **data was cached to RAM memory, not to the disk**<code bash>
 +dd if=/dev/zero of=speetest bs=1M count=100
 +</code>output:<code>
 +100+0 records in
 +100+0 records out
 +104857600 bytes (105 MB) copied, 0.102163 s, 1.0 GB/s
 +</code>
 +  * Ask dd command to report the speed only **after the data is synced with the disk**<code bash>
 +dd if=/dev/zero of=speetest bs=1M count=100 conv=fdatasync
 +</code>output:<code>
 +100+0 records in
 +100+0 records out
 +104857600 bytes (105 MB) copied, 1.12073 s, 93.6 MB/s
 +</code>
 +==== Using hdparm ====
 +<code bash>
 +hdparm -tT /dev/sdb1
 +</code>output:<code>
 +/dev/sdb1:
 + Timing cached reads:   12982 MB in  2.00 seconds = 6500.84 MB/sec
 + Timing buffered disk reads: 346 MB in  3.01 seconds = 115.04 MB/sec
 +</code>
benchmarking.txt · Last modified: 2022/10/29 16:15 by 127.0.0.1