Difference between revisions of "Ab"

From OnnoWiki
Jump to navigation Jump to search
Line 82: Line 82:
 
  ab -n 10000 -c 400 http://192.168.0.100/index.html
 
  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 1000 -c 10 -g test_data_1.txt http://www.your-domain.com/index.html
 +
ab -n 10000 -c 400 -g test_data_1.txt http://192.168.0.238/DVWA-1.9/login.php
 +
  
 
Hasilnya:
 
Hasilnya:

Revision as of 17:21, 19 November 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-get install apache2-utils tcpdump

Normal Benchmark

ab -kc 20 -t 60 http://192.168.0.100/index.html

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 -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