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

  • Inilah 7 Ide Channel YouTube Aneh Tapi Sederhana yang Bisa Kalian Mulai Sekarang Juga!
  • Apa itu Umroh & Keutamaannya: Inspirasi dari pergiumroh.com
  • Belum Tahu? Gini Caranya Dapat Bisnis Sukses Cuma dari Clipping Video Pake AI
  • Inilah Rahasia Perbaiki Algoritma Video YouTube yang Mulai Sepi
  • Kenapa Cicilan di Bank Syariah Itu Tetap?
  • Inilah 7 Produk Digital Paling Realistis untuk Kalian yang Mau Jualan Online Tahun Ini!
  • Inilah 4 Strategi Memilih Niche SEO Terbaik Supaya Blog Kalian Cepat Ranking
  • Ini Trik Supaya Pengunjung Toko Online Kalian Jadi Pembeli Setia Pakai Omnisend!
  • 3 Strategi AI Terbukti Biar Bisnis E-Commerce Kalian Makin Cuan 2026!
  • Inilah 6 Langkah Tembus 5.000 Follower di X, Gini Caranya Supaya Akun Kalian Nggak Stuck Lagi!
  • SEO LinkedIn: Inilah Alasan Kenapa LinkedIn Ads Lebih Efektif Buat Bisnis B2B Dibanding Platform Lain
  • Inilah Alasan Kenapa Kolom Komentar YouTube Kalian Sering Menghilang Secara Misterius!
  • Cara Kelola Auto-Posting Semua Media Sosial Kalian Pakai Metricool
  • Studi Kasus Sukses Instagram Maria Wendt Dapat 12 Juta View Instagram Per Bulan
  • ZenBook S16, Vivobook Pro 15 OLED, ProArt PX13, dan ROG Zephyrus G14, Laptop Bagus dengan Layar OLED!
  • Caranya Ngebangun Website Directory dengan Traffic Tinggi dalam Seminggu!
  • Cara Mengembangkan Channel YouTube Shorts Tanpa Wajah
  • Inilah Cara Menghitung Diskon Baju Lebaran Biar Nggak Bingung Saat Belanja di Mall!
  • Cara Jitu Ngebangun Bisnis SaaS di Era AI Pakai Strategi Agentic Workflow
  • Inilah Rincian Gaji Polri Lulusan Baru 2026, Cek Perbedaan Jalur Akpol, Bintara, dan Tamtama Sebelum Daftar!
  • Inilah 5 Channel YouTube Membosankan yang Diam-diam Menghasilkan Banyak Uang
  • Inilah Cara Pakai Google Maps Offline Biar Mudik Lebaran 2026 Nggak Nyasar Meski Tanpa Sinyal!
  • Inilah Alasan Mahkamah Agung Tolak Kasasi Google, Denda Rp202,5 Miliar Resmi Menanti Akibat Praktik Monopoli
  • Inilah Cara Daftar dan Syarat SPMB SMK Boarding Jawa Tengah 2026, Sekolah Gratis Sampai Lulus!
  • Inilah Daftar Sekolah Kedinasan 2026 untuk Lulusan SMK, Bisa Kuliah Gratis dan Berpeluang Besar Langsung Jadi CPNS!
  • Inilah Pajak TER: Skema Baru PPh 21 yang Nggak Bikin Pusing, Begini Cara Hitungnya!
  • Inilah Jadwal Resmi Jam Buka Tol Jogja-Solo Segmen Prambanan-Purwomartani Saat Mudik Lebaran 2026
  • Inilah Cara Mendapatkan Witherbloom di Fisch Roblox, Rahasia Menangkap Ikan Paling Sulit di Toxic Grove!
  • Kenapa Indomart Point Bisa Kalahkan Bisnis Kafe?
  • Inilah Cara Mendapatkan Rotten Seed di Fisch Roblox, Lokasi Rahasia di Toxic Grove Buat Unlock Toxic Lotus!
  • How to Fix VMSp Service Failed to Start on Windows 10/11
  • How to Fix Taskbar Icon Order in Windows 11/10
  • How to Disable Personalized Ads in Copilot on Windows 11
  • What is the Microsoft Teams Error “We Couldn’t Connect the Call” Error?
  • Why Does the VirtualBox System Service Terminate Unexpectedly? Here is the Full Definition
  • How to Use Orbax Checkpointing with Keras and JAX for Robust Training
  • How to Automate Any PDF Form Using the Power of Manus AI
  • How to Training Your Own YOLO26 Object Detection Model!
  • How to Build a Full-Stack Mobile App in Minutes with YouWare AI
  • How to Create Consistent Characters and Cinematic AI Video Production with Seedance
  • Apa itu Spear-Phishing via npm? Ini Pengertian dan Cara Kerjanya yang Makin Licin
  • Apa Itu Predator Spyware? Ini Pengertian dan Kontroversi Penghapusan Sanksinya
  • Mengenal Apa itu TONESHELL: Backdoor Berbahaya dari Kelompok Mustang Panda
  • Siapa itu Kelompok Hacker Silver Fox?
  • Apa itu CVE-2025-52691 SmarterMail? Celah Keamanan Paling Berbahaya Tahun 2025

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