Skip to content

emka.web.id

menulis pengetahuan – merekam peradaban

Menu
  • Home
  • Tutorial
  • Search
Menu

How to benchmarking Apache Tomcat with ab (Apache Bench)

Posted on August 14, 2013

Typically when you want to measure tomcat performance, you will set up the client on a separate machine so that when you are doing testing the client resource usage does not impact the test.

Measuring with Apache Bench

The Apache Bench will probably be installed by default on the Ubuntu server.  What this tool does is to allow you to select one URL and test against that single URL.  In the test that you see below ab was told to retrieve the web URL 100,000 times with a concurrency maximum of 149, since the max is 150 by default with tomcat.

The max threads are listed in the /usr/share/tomcat7/conf/server.xml file as seen here.

[sourcecode]
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
[/sourcecode]

An important point to make here is that you want to perform enough requests to get an accurate view of performance.  Most bench marks will be best with over 100,000 requests.  The “-k” causes ab to use keep-alive connections which is more efficient but maybe not representative of your situation so try both ways to get a understanding of the differences.

ab -k -n 100000 -c 149 http://192.168.5.44:8080/
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 192.168.5.44 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests

Server Software:        Apache-Coyote/1.1
Server Hostname:        192.168.5.44
Server Port:            8080

Document Path:          /
Document Length:        11850 bytes

Concurrency Level:      149
Time taken for tests:   101.501 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      1207100000 bytes
HTML transferred:       1185000000 bytes
Requests per second:    985.21 [#/sec] (mean)
Time per request:       151.237 [ms] (mean)
Time per request:       1.015 [ms] (mean, across all concurrent requests)
Transfer rate:          11613.74 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0   61 204.1     47    3151
Processing:     3   90 158.2     64    2509
Waiting:        0   65 158.9     40    2476
Total:          4  150 259.0    119    4306

Percentage of the requests served within a certain time (ms)
50%    119
66%    121
75%    122
80%    122
90%    134
95%    189
98%    611
99%   1388
100%   4306 (longest request)

Once the test is complete take a look at the use of tcp_max_tw_buckets as you will certainly see how long it take to break down the tcp connections to your server.

tcp6      86      0 192.168.5.44:8080 192.168.5.44:34064 CLOSE_WAIT
tcp6       0      0 192.168.5.44:8080 192.168.5.44:33955 CLOSE_WAIT
tcp6      86      0 192.168.5.44:8080 192.168.5.44:34027 CLOSE_WAIT
tcp6       1      0 192.168.5.44:8080 192.168.5.44:33912 CLOSE_WAIT
tcp6      86      0 192.168.5.44:8080 192.168.5.44:34025 CLOSE_WAIT
tcp6       1      0 192.168.5.44:8080 192.168.5.44:39259 CLOSE_WAIT
tcp6      86      0 192.168.5.44:8080 192.168.5.44:34063 CLOSE_WAIT
tcp6      86      0 192.168.5.44:8080 192.168.5.44:34082 CLOSE_WAIT
tcp6       1      0 192.168.5.44:8080 192.168.5.44:33849 CLOSE_WAIT
tcp6      86      0 192.168.5.44:8080 192.168.5.44:34062 CLOSE_WAIT
—cut—

Once a test has been performed you may want to increase the tcp_max_tw_buckets setting.  First, list the current settings with:

cat /proc/sys/net/ipv4/tcp_max_tw_buckets
65536
echo 2000000 > /proc/sys/net/ipv4/tcp_max_tw_buckets

ab -k -n 100000 -c 149 http://192.168.5.44:8080/
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 192.168.5.44 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests

Server Software:        Apache-Coyote/1.1
Server Hostname:        192.168.5.44
Server Port:            8080

Document Path:          /
Document Length:        11850 bytes

Concurrency Level:      149
Time taken for tests:   99.644 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      1207100000 bytes
HTML transferred:       1185000000 bytes
Requests per second:    1003.57 [#/sec] (mean)
Time per request:       148.470 [ms] (mean)
Time per request:       0.996 [ms] (mean, across all concurrent requests)
Transfer rate:          11830.18 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0   61 199.5     47    3100
Processing:     4   87 157.1     63    7623
Waiting:        1   64 155.7     40    7595
Total:          8  148 251.6    118    7630

Percentage of the requests served within a certain time (ms)
50%    118
66%    120
75%    121
80%    122
90%    145
95%    185
98%    440
99%   1408
100%   7630 (longest request)

Here is an example of the result with no “-k” keep-alive connections. What you can see is a dramatic difference in time and as a result it reached the timeout and quit.

ab -n 100000 -c 149 http://192.168.5.44:8080/
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 192.168.5.44 (be patient)
Completed 10000 requests
Completed 20000 requests
apr_poll: The timeout specified has expired (70007)
Total of 28621 requests completed

via BeginLinux

Terbaru

  • Video Melolo Cuma Layar Hitam? Ini Trik Ampuh Mengatasinya, Pasti Berhasil!
  • Mau Simpan Video Twitter dan TikTok Tanpa Aplikasi? Begini Cara Praktis Pakai VidsSave!
  • Mau Gaji Dolar? Gini Caranya Tembus Kerja di Australia, Jangan Sampai Salah Visa!
  • Belum Tahu? Inilah Fakta MigoReels, Katanya Nonton Drama Bisa Dapat Rp700 Ribu!
  • Apa Itu Event Invite Friends CapCut? Ini Pengertian dan Cara Kerjanya Biar Cuan
  • Apa Itu MJ di FF? Ini Pengertian, Asal-Usul, dan Risiko di Balik Istilah Tersebut
  • Apa Itu Pengertian Penonaktifan SPayLater? Ini Durasi Blokir Akibat Telat Bayar
  • Apa Itu Rasio Gambar Ukuran 1:1 di Canva? Ini Pengertian dan Cara Buatnya
  • Pengiriman Shopee Express Hemat itu Berapa Lama? Ini Pengertian dan Estimasi Sampainya
  • Android 2025: Aplikasi Baru dan Smartphone Impian yang Akan Datang!
  • Apa Itu Google AI Pro Ultra? Ini Pengertian dan Penjelasan Lengkapnya
  • Apa Itu Error Gagal Kirim Nilai RDM 3.1? Ini Pengertian dan Solusi Mengatasinya
  • Facebook Mulai Batasi Link Eksternal Cuma 2 Sebulan! Ini Trik Mengatasinya
  • Cara Nonton Tensura Season 4! Bakal Tayang April 2026 dengan Format 5 Cour
  • Belum Tahu? Inilah Trik Supaya Live TikTok Kalian Aman dan Banjir Cuan
  • Pixel 8 Dapatkan Mode Panorama Baru! Hasil Foto Lebih Luas & Lebih Kreatif
  • Apa Itu AppLocker? Ini Pengertian dan Cara Mengamankan Windows 11 Kalian dari Skrip Jahat
  • Cara Membuat Riwayat Copilot Kamu Tetap Bersih dan Rapi!
  • Game & Aplikasi Android Terbaik Saat Diskon Liburan Natal! Jangan Ketinggalan!
  • Apa Itu Game Prison Escape Journey? Ini Pengertian dan Cara Mainnya untuk Pemula
  • “Listrik Gratis” dari Solar Panel Cuma Mitos?! Ini Sisi Gelap PLTS
  • Samsung Galaxy Z-Fold: Uji Jatuh Bebas yang Mengguncang Keandalan Lipatannya
  • Google One 2026: Apa yang Akan Jadi Fitur Utama dan Harga yang Diharapkan?
  • Apa Itu Error 0x800704f8? Ini Pengertian dan Cara Mengatasinya
  • Android Akhirnya Dapat GPS Darurat di India! Setelah Hampir 10 Tahun
  • Apa Itu GetContact Premium? Ini Pengertian dan Cara Daftarnya
  • Android Maze Figure: Koleksi Baru Google yang Bikin Penggemar Bergairah!
  • Google Update Besar-besaran Desember 2025: Apa yang Akan Memengaruhi Pengalaman Anda?
  • Masih Pusing Hitung Gaji Manual? Waktunya Pakai Aplikasi HR
  • Apa Itu Dustruco? Ini Pengertian dan Cara Pasangnya di HP Kalian
  • Apa itu Cosmic Desktop: Pengertian dan Cara Pasangnya di Ubuntu 26.04?
  • Apa Itu Auvidea X242? Pengertian Carrier Board Jetson T5000 dengan Dual 10Gbe
  • Elementary OS 8.1 Resmi Rilis: Kini Pakai Wayland Secara Standar!
  • Apa Itu Raspberry Pi Imager? Pengertian dan Pembaruan Versi 2.0.3 yang Wajib Kalian Tahu
  • Performa Maksimal! Ini Cara Manual Update Ubuntu ke Linux Kernel 6.18 LTS
  • Begini Cara Menjalankan Notebook Machine Learning di Databricks, Gratis dan Tanpa Ribet!
  • Apa Itu PeakAI? Ini Pengertian dan Cara Menghasilkan Uang dari Kolaborasi TikTok
  • Inilah Cara Ubah Rutinitas Browsing Lebih Produktif dengan Perplexity Comet (AI Browser)
  • Inilah Cara Kuasai Materi Sulit dalam Hitungan Menit Pakai Google NotebookLM: Tutorial Lengkap
  • Inilah Cara Membuat AI Agent Cerdas dan Memantaunya Menggunakan LangGraph dan LangSmith
  • Apa Itu Raccoon0365? Ini Pengertian dan Bahaya Platform Phishing Microsoft
  • Apa Itu Raccoon Framework? Ini Pengertian dan Asal Usulnya
  • Apa Itu Serangan Phishing OAuth di Microsoft 365? Ini Definisi dan Cara Kerjanya
  • Apa Itu Distribusi Malware Via YouTube? Ini Pengertian dan Bahayanya Buat Kalian
  • Apa Itu Undang-Undang NDAA? Ini Pengertian dan Dampaknya Bagi Cyber Command Amerika Serikat
Beli Pemotong Rumput dengan Baterai IRONHOOF 588V Mesin Potong Rumput 88V disini https://s.shopee.co.id/70DBGTHtuJ
Beli Morning Star Kursi Gaming/Kantor disini: https://s.shopee.co.id/805iTUOPRV

©2025 emka.web.id | Design: Newspaperly WordPress Theme