Difference between revisions of "Ab"

From OnnoWiki
Jump to navigation Jump to search
(New page: Performance Testing your Web Server To benchmark the performance of your web server applications we recommend the Apache "ab" tool. The ab tool will show how many requests per second you...)
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
Performance Testing your Web Server
+
Benchmark Performance Apache
  
To benchmark the performance of your web server applications we recommend the Apache "ab" tool.  The ab tool will show how many requests per second your Apache installation is capable of serving. The ab tool is a part of the Apache httpd package in CentOS and Red Hat distributions and the "apache2-utils" package in Debian.
+
Apache "ab" tool dapat digunakan untuk mengukur berapa request per second yang dapat di tangani oleh apache yang kita install.
 +
Di Debian termasuk dalam paket "apache2-utils"
  
Below is the basic ab command and its output.  The -c parameter specifies the number of connections; the -k stands for HTTP Keep-Alive; and the -t parameter sets the time in seconds for which each connection is alive.  The application is then hammered through those connections.
+
==Instalasi ab==
  
# ab -kc 20 -t 60 http://8.19.73.87/index.html
+
apt update
 +
apt install apache2-utils tcpdump
  
Benchmarking 8.19.73.87 (be patient)
+
==Normal Benchmark==
Finished 130 requests
 
  
 +
ab -kc 20 -t 60 http://192.168.0.100/index.html
 +
ab -kc 20 -t 60 http://192.168.0.3:8080/wikipedia_id_all_novid_2018-07/
  
Server Software:        Apache/2.2.3
+
Dimana
Server Hostname:        8.19.73.87
 
Server Port:            80
 
  
Document Path:          /index.html
+
-c banyaknya connections
Document Length:        283 bytes
+
-k HTTP Keep-Alive
 +
-t detik setiap connection harus alive
  
Concurrency Level:     20
+
Hasilnya:
Time taken for tests:  62.269650 seconds
 
Complete requests:      130
 
Failed requests:        0
 
Write errors:          0
 
Non-2xx responses:      130
 
Keep-Alive requests:    0
 
Total transferred:      60060 bytes
 
HTML transferred:      36790 bytes
 
Requests per second:    2.09 [#/sec] (mean)
 
Time per request:      9579.946 [ms] (mean)
 
Time per request:      478.997 [ms] (mean, across all concurrent requests)
 
Transfer rate:          0.93 [Kbytes/sec] received
 
  
Connection Times (ms)
+
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
              min mean[+/-sd] median  max
+
  Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Connect:     206 392 637.2    250    3325
+
Licensed to The Apache Software Foundation, http://www.apache.org/
Processing: 4523 8222 3030.7   8016  13982
+
   
Waiting:     208 4798 2958.5  4212  10838
+
Benchmarking 192.168.0.100 (be patient)
Total:       4813 8614 3120.1  8329  14269
+
Completed 5000 requests
 +
Completed 10000 requests
 +
Completed 15000 requests
 +
Completed 20000 requests
 +
Completed 25000 requests
 +
Completed 30000 requests
 +
Completed 35000 requests
 +
Completed 40000 requests
 +
Completed 45000 requests
 +
Completed 50000 requests
 +
Finished 50000 requests
 +
 +
Server Software:       Apache/2.4.7
 +
Server Hostname:       192.168.0.100
 +
Server Port:            80
 +
 +
Document Path:         /index.html
 +
Document Length:        11510 bytes
  
Percentage of the requests served within a certain time (ms)
+
Concurrency Level:      20
  50%   8329
+
Time taken for tests:  48.136 seconds
  66% 10851
+
Complete requests:      50000
  75% 10998
+
Failed requests:        0
  80% 11128
+
Keep-Alive requests:    49516
  90% 13933
+
Total transferred:      590928707 bytes
  95% 14056
+
HTML transferred:      575500000 bytes
  98% 14189
+
Requests per second:    1038.71 [#/sec] (mean)
  99% 14223
+
Time per request:      19.255 [ms] (mean)
100% 14269 (longest request)
+
Time per request:      0.963 [ms] (mean, across all concurrent requests)
 +
Transfer rate:          11988.40 [Kbytes/sec] received
 +
 +
Connection Times (ms)
 +
              min  mean[+/-sd] median  max
 +
Connect:        0    0  0.2      0      11
 +
Processing:    1  19  14.2    19    109
 +
Waiting:        0  13  10.3    11      93
 +
Total:          1  19  14.2    19    109
 +
 +
Percentage of the requests served within a certain time (ms)
 +
  50%     19
 +
  66%     26
 +
  75%     30
 +
  80%     32
 +
  90%     38
 +
  95%     43
 +
  98%     49
 +
  99%     53
 +
  100%   109 (longest request)
  
    To perform a "flood" test we set the number of requests (-n) to, say, 5000, and assign the number of concurrent connections{{ (-c}}) to something like 200:
+
==Flood Test==
  
    # ab -n 5000 -c 200 http://8.19.73.87/index.html
+
Mencoba untuk "flood" test, mengirim request (-n) misalnya 5000 dan concurrent connections (-c) misalnya 2000.
  
    Benchmarking 8.19.73.87 (be patient)
 
    Finished 316 requests
 
  
 +
ab -n 10000 -c 400 http://192.168.0.100/index.html
 +
ab -n 1000 -c 10 -g test_data_1.txt http://www.your-domain.com/index.html
 +
ab -n 10000 -c 400 -A admin:password -g test_data_1.txt http://192.168.0.238/DVWA-1.9/login.php
  
    Server Software:        Apache/2.2.3
 
    Server Hostname:        8.19.73.87
 
    Server Port:            80
 
  
    Document Path:         /index.html
+
Hasilnya:
    Document Length:        283 bytes
 
  
    Concurrency Level:      1
+
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
    Time taken for tests:  203.610963 seconds
+
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Complete requests:      316
+
Licensed to The Apache Software Foundation, http://www.apache.org/
    Failed requests:        0
+
    Write errors:          0
+
Benchmarking 192.168.0.100 (be patient)
    Non-2xx responses:      316
+
Completed 1000 requests
    Total transferred:      145992 bytes
+
Completed 2000 requests
    HTML transferred:      89428 bytes
+
Completed 3000 requests
    Requests per second:    1.55 [#/sec] (mean)
+
Completed 4000 requests
    Time per request:      644.338 [ms] (mean)
+
Completed 5000 requests
    Time per request:      644.338 [ms] (mean, across all concurrent requests)
+
Completed 6000 requests
    Transfer rate:          0.70 [Kbytes/sec] received
+
Completed 7000 requests
 +
Completed 8000 requests
 +
Completed 9000 requests
 +
Completed 10000 requests
 +
Finished 10000 requests
 +
 +
Server Software:        Apache/2.4.7
 +
Server Hostname:        192.168.0.100
 +
Server Port:            80
 +
 +
Document Path:          /index.html
 +
Document Length:        11510 bytes
 +
 +
Concurrency Level:      400
 +
Time taken for tests:  7.447 seconds
 +
Complete requests:      10000
 +
Failed requests:        0
 +
Total transferred:      117830000 bytes
 +
HTML transferred:      115100000 bytes
 +
Requests per second:    1342.82 [#/sec] (mean)
 +
Time per request:      297.882 [ms] (mean)
 +
Time per request:      0.745 [ms] (mean, across all concurrent requests)
 +
Transfer rate:          15451.55 [Kbytes/sec] received
 +
 +
Connection Times (ms)
 +
              min  mean[+/-sd] median  max
 +
Connect:        1  112 248.7    51    3076
 +
Processing:    13  173 172.1    127    2376
 +
Waiting:        8  151 161.3    111    2317
 +
Total:        42  285 306.9    188    3407
 +
 +
Percentage of the requests served within a certain time (ms)
 +
  50%    188
 +
  66%    221
 +
  75%    266
 +
  80%    314
 +
  90%    474
 +
  95%  1157
 +
  98%  1219
 +
  99%  1317
 +
  100%  3407 (longest request)
  
    Connection Times (ms)
+
==Cek tcpdump==
                  min  mean[+/-sd] median  max
 
    Connect:      206  340 509.5    250    3324
 
    Processing:  207  302 450.1    250    7830
 
    Waiting:      206  285 201.5    250    2693
 
    Total:        414  643 683.4    501    8081
 
  
    Percentage of the requests served within a certain time (ms)
+
Jika keluaran ab mencurigakan, kita bisa melihat reply di tcpdump.
      50%    501
+
Terutama kita perlu menangkap reply tcp-rst yang muncul
      66%    505
 
      75%    579
 
      80%    645
 
      90%    651
 
      95%  1313
 
      98%  3648
 
      99%  3649
 
    100%  8081 (longest request)
 
  
    If the ab output makes you suspect issues, it is useful to look into any replies using tcpdump.  In particular, tcp-rst replies could appear.  To catch them, use:
+
tcpdump -nn 'tcp[tcpflags] == tcp-rst' and port 80
  
    # tcpdump -nn 'tcp[tcpflags] == tcp-rst' and port 80
+
Hasilnya:
  
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
+
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
+
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    10:59:06.036411 IP 89.253.250.50.53261 > 8.19.73.87.80: R 179261015:179261015(0) win 0
+
17:46:40.209978 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
    10:59:06.036521 IP 89.253.250.50.53261 > 8.19.73.87.80: R 179261015:179261015(0) win 0
+
17:46:40.210022 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
    10:59:06.036553 IP 89.253.250.50.53261 > 8.19.73.87.80: R 179261016:179261016(0) win 0
+
17:46:40.210092 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
 +
17:46:40.210276 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
 +
17:46:40.210325 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
 +
17:46:40.210418 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
 +
17:46:40.210522 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
 +
17:46:40.210566 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
 +
17:46:40.210863 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
  
    We are interested mostly in tcp-rst server replies, as they point to misconfiguration or performance issues.  To catch server-side tcp-rst replies use:
+
Kalau kita hanya tertarik pada tcp-rst reply dari server, gunakan:
  
    # tcpdump -nn 'tcp[tcpflags] == tcp-rst' and port 80 and src host 89.253.250.50
+
tcpdump -nn 'tcp[tcpflags] == tcp-rst' and port 80 and src host 192.168.0.100
  
    where 89.253.250.50 is the server hosting your tests.
+
dimana 192.168.0.100 adalah IP server.
  
  
  
 +
==GNU plot untuk view loading data==
  
 +
Interactive session:
 +
 +
$ gnuplot
 +
gnuplot> set terminal png
 +
gnuplot> set output "ApacheBenchmarkResults.png"
 +
gnuplot> set title "Benchmark from Server X"
 +
gnuplot> set size 1,0.5
 +
gnuplot> set key left top
 +
gnuplot> set xlabel 'request'
 +
gnuplot> set ylabel 'ms'
 +
gnuplot> plot "test_data_1.txt" using 10 with lines title 'Benchmark from Server X'
 +
gnuplot> exit
 +
 +
or as a script:
 +
 +
#!/usr/bin/gnuplot
 +
# Script to plot web server load
 +
set terminal png
 +
set output "ApacheBenchmarkResults.png"
 +
set title "Benchmark from Server X"
 +
set size 1,0.5
 +
set key left top
 +
set xlabel 'request'
 +
set ylabel 'ms'
 +
plot "test_data_1.txt" using 10 with lines title 'Benchmark from Server X'
  
  
Line 120: Line 202:
  
 
* https://wiki.appnexus.com/display/documentation/How+to+Apache+Stress+Test+With+ab+Tool
 
* https://wiki.appnexus.com/display/documentation/How+to+Apache+Stress+Test+With+ab+Tool
 +
 +
 +
==Pranala Menarik==
 +
 +
* [[ab: 7 tip untuk heavy load ab benchmark]]
 +
* [[Network Benchmarking]]

Latest revision as of 10:24, 12 December 2018

Benchmark Performance Apache

Apache "ab" tool dapat digunakan untuk mengukur berapa request per second yang dapat di tangani oleh apache yang kita install. Di Debian termasuk dalam paket "apache2-utils"

Instalasi ab

apt update
apt install apache2-utils tcpdump

Normal Benchmark

ab -kc 20 -t 60 http://192.168.0.100/index.html
ab -kc 20 -t 60 http://192.168.0.3:8080/wikipedia_id_all_novid_2018-07/

Dimana

-c banyaknya connections
-k HTTP Keep-Alive
-t detik setiap connection harus alive

Hasilnya:

This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.0.100 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requests

Server Software:        Apache/2.4.7
Server Hostname:        192.168.0.100
Server Port:            80

Document Path:          /index.html
Document Length:        11510 bytes
Concurrency Level:      20
Time taken for tests:   48.136 seconds
Complete requests:      50000
Failed requests:        0
Keep-Alive requests:    49516
Total transferred:      590928707 bytes
HTML transferred:       575500000 bytes
Requests per second:    1038.71 [#/sec] (mean)
Time per request:       19.255 [ms] (mean)
Time per request:       0.963 [ms] (mean, across all concurrent requests)
Transfer rate:          11988.40 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0      11
Processing:     1   19  14.2     19     109
Waiting:        0   13  10.3     11      93
Total:          1   19  14.2     19     109

Percentage of the requests served within a certain time (ms)
  50%     19
  66%     26
  75%     30
  80%     32
  90%     38
  95%     43
  98%     49
  99%     53
 100%    109 (longest request)

Flood Test

Mencoba untuk "flood" test, mengirim request (-n) misalnya 5000 dan concurrent connections (-c) misalnya 2000.


ab -n 10000 -c 400 http://192.168.0.100/index.html
ab -n 1000 -c 10 -g test_data_1.txt http://www.your-domain.com/index.html
ab -n 10000 -c 400 -A admin:password -g test_data_1.txt http://192.168.0.238/DVWA-1.9/login.php


Hasilnya:

This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.0.100 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software:        Apache/2.4.7
Server Hostname:        192.168.0.100
Server Port:            80

Document Path:          /index.html
Document Length:        11510 bytes

Concurrency Level:      400
Time taken for tests:   7.447 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      117830000 bytes
HTML transferred:       115100000 bytes
Requests per second:    1342.82 [#/sec] (mean)
Time per request:       297.882 [ms] (mean)
Time per request:       0.745 [ms] (mean, across all concurrent requests)
Transfer rate:          15451.55 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1  112 248.7     51    3076
Processing:    13  173 172.1    127    2376
Waiting:        8  151 161.3    111    2317
Total:         42  285 306.9    188    3407

Percentage of the requests served within a certain time (ms)
  50%    188
  66%    221
  75%    266
  80%    314
  90%    474
  95%   1157
  98%   1219
  99%   1317
 100%   3407 (longest request)

Cek tcpdump

Jika keluaran ab mencurigakan, kita bisa melihat reply di tcpdump. Terutama kita perlu menangkap reply tcp-rst yang muncul

tcpdump -nn 'tcp[tcpflags] == tcp-rst' and port 80

Hasilnya:

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
17:46:40.209978 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
17:46:40.210022 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
17:46:40.210092 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
17:46:40.210276 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
17:46:40.210325 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
17:46:40.210418 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
17:46:40.210522 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
17:46:40.210566 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0
17:46:40.210863 IP 192.168.0.101.36311 > 192.168.0.100.80: Flags [R], seq 2078245274, win 0, length 0

Kalau kita hanya tertarik pada tcp-rst reply dari server, gunakan:

tcpdump -nn 'tcp[tcpflags] == tcp-rst' and port 80 and src host 192.168.0.100

dimana 192.168.0.100 adalah IP server.


GNU plot untuk view loading data

Interactive session:

$ gnuplot
gnuplot> set terminal png
gnuplot> set output "ApacheBenchmarkResults.png"
gnuplot> set title "Benchmark from Server X"
gnuplot> set size 1,0.5
gnuplot> set key left top
gnuplot> set xlabel 'request'
gnuplot> set ylabel 'ms'
gnuplot> plot "test_data_1.txt" using 10 with lines title 'Benchmark from Server X'
gnuplot> exit

or as a script:

#!/usr/bin/gnuplot
# Script to plot web server load
set terminal png
set output "ApacheBenchmarkResults.png"
set title "Benchmark from Server X"
set size 1,0.5
set key left top
set xlabel 'request'
set ylabel 'ms'
plot "test_data_1.txt" using 10 with lines title 'Benchmark from Server X'


Referensi


Pranala Menarik