Setelah kita melakukan pengembangan aplikasi terutama dengan framework Yii, tentu kita ingin melihat sampai seberapa kuat server kita. Kita ingin melihat performance dari web server dan juga database server kita. Berikut langkah-langkah mengukur performance server web dan juga server database kita menggunakan ApacheBench atau Apache HTTP server benchmarking tool .
Misal kita ingin menghitung performance dari webserver https://contohsaja.com/scriptbiasa . Misalnya dalam web server ini kita juga terhubung dengan database server yang lain.
- Silahkan login ke server Linux lain yang dekat dengan https://contohsaja.com/scriptbiasa . Cari file ab (merupakan file Apache untuk Benchmarking) dan jalankan perintah dengan contoh seperti di bawah ini:
# ./ab -n 1000 -c 40 https://contohsaja.com/scriptbiasa
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 contohsaja.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requestsServer Software: Apache/2.4.9
Server Hostname: contohsaja.com
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256Document Path: /scriptbiasa
Document Length: 10583 bytesConcurrency Level: 40
Time taken for tests: 147.315 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 10991000 bytes
HTML transferred: 10583000 bytes
Requests per second: 6.79 [#/sec] (mean)
Time per request: 5892.599 [ms] (mean)
Time per request: 147.315 [ms] (mean, across all concurrent requests)
Transfer rate: 72.86 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 9 217 809.1 37 6303
Processing: 649 5635 826.9 5588 7862
Waiting: 620 5354 784.9 5306 7625
Total: 682 5852 1126.3 5648 12422Percentage of the requests served within a certain time (ms)
50% 5648
66% 5892
75% 6126
80% 6413
90% 6987
95% 7489
98% 9417
99% 11072
100% 12422 (longest request) - Kita juga dapat memantau penggunaan memory pada server contohsaja.com dengan perintah top:
Tasks: 127 total, 1 running, 125 sleeping, 0 stopped, 1 zombie
Cpu(s): 71.3%us, 7.5%sy, 0.0%ni, 18.9%id, 0.0%wa, 0.0%hi, 2.3%si, 0.0%st
Mem: 1020400k total, 777040k used, 243360k free, 141084k buffers
Swap: 0k total, 0k used, 0k free, 181320k cachedPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
32469 prowebin 20 0 429m 14m 5044 S 3.9 1.5 0:02.72 /opt/lampp/bin/
32476 prowebin 20 0 429m 14m 5044 S 3.9 1.5 0:02.71 /opt/lampp/bin/
32422 prowebin 20 0 429m 14m 5044 S 3.6 1.5 0:02.93 /opt/lampp/bin/
32455 prowebin 20 0 429m 14m 5044 S 3.6 1.5 0:02.72 /opt/lampp/bin/
32459 prowebin 20 0 429m 14m 5048 S 3.6 1.5 0:02.72 /opt/lampp/bin/ - Begitu juga kita dapat memantau database servernya dengan printah top misalnya:
Tasks: 73 total, 1 running, 72 sleeping, 0 stopped, 0 zombie
Cpu(s): 15.1%us, 5.1%sy, 0.0%ni, 77.1%id, 1.4%wa, 0.0%hi, 0.7%si, 0.7%st
Mem: 1020400k total, 668012k used, 352388k free, 80372k buffers
Swap: 0k total, 0k used, 0k free, 322536k cachedPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1434 mysql 20 0 884m 169m 8896 S 21.0 17.0 5:13.09 mysqld
985 root 20 0 0 0 0 S 0.3 0.0 0:01.06 kjournald
1 root 20 0 19232 1496 1220 S 0.0 0.1 0:00.70 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.03 kthreadd
Informasi lebih lanjut silahkan membaca :
1. http://httpd.apache.org/docs/2.2/programs/ab.html
2. http://en.wikipedia.org/wiki/ApacheBench .
3. http://www.yiiframework.com/performance/ .
Kunjungi www.proweb.co.id untuk menambah wawasan anda.