Skip to content

emka.web.id

Menu
  • Home
  • Indeks Artikel
  • Tutorial
  • Tentang Kami
Menu

How to benchmarking Apache Tomcat with ab (Apache Bench)

Posted on August 14, 2013 by Syauqi Wiryahasana
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
Seedbacklink

Recent Posts

TENTANG EMKA.WEB>ID

EMKA.WEB.ID adalah blog seputar teknologi informasi, edukasi dan ke-NU-an yang hadir sejak tahun 2011. Kontak: kontak@emka.web.id.

©2024 emka.web.id Proudly powered by wpStatically