Home arrow BrainDump arrow Page 3 - Tomcat Performance Tuning

ab: The Apache benchmark tool - BrainDump

If you want a "pure Java" HTTP web server environment for Java code to run on, you may have already discovered Tomcat. This five-part article series shows you how to tune Tomcat's performance and increase its efficiency. It is excerpted from chapter four of Tomcat: The Definitive Guide, Second Edition, written by Jason Brittain and Ian F. Darwin (O'Reilly; ISBN: 0596101066). Copyright © 2008 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

TABLE OF CONTENTS:
  1. Tomcat Performance Tuning
  2. Measuring Web Server Performance
  3. ab: The Apache benchmark tool
  4. Siege
By: O'Reilly Media
Rating: starstarstarstarstar / 9
February 12, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The ab tool takes a single URL and requests it repeatedly in as many separate threads as you specify, with a variety of command-line arguments to control the number of times to fetch it, the maximum thread concurrency, and so on. A couple of nice features include the optional printing of progress reports periodically and the comprehensive report it issues.

Example 4-1 is an example running ab. We instructed it to fetch the URL 100,000 times with a maximum concurrency of 149 threads. We chose these numbers carefully. The smaller the number of HTTP requests that the test client makes during the benchmark test, the more likely the test client will give less accurate results because during the benchmark the Java VMís garbage collector pauses make up a higher percentage of the total testing time. The higher the total number of HTTP requests that you run, the less significant the garbage collector pauses become and the more likely the benchmark results will show how Tomcat performs overall. You should benchmark by running a minimum of 100,000 HTTP requests. Also, you may configure the test client to spawn as many client threads as you would like, but you will not get helpful results if you set it higher than themaxThreads you set for yourConnectorin your Tomcatís conf/server.xml file. By default, it is set to150. If you set your tester to exceed this number and make more requests in more threads than Tomcat has threads to receive and process them, performance will suffer because some client request threads will always be waiting. It is best to stay just under the number of yourConnectorísmaxThreads, such as using 149 client threads.

Example 4-1. Benchmarking with ab

$ ab -k -n 100000 -c 149 http://tomcathost:8080
This is ApacheBench, Version 2.0.40-dev <$Revision$> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 1997-2005 The Apache Software Foundation, http://www.apache.org/

Benchmarking tomcathost (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
Finished 100000 requests

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

Document Path:             /
Document Length:           8132 bytes

 

 

Concurrency Level:         149
Time taken for tests:      19.335590 seconds Complete requests:         100000
Failed requests:           0
Write errors:              0
Keep-Alive requests:       79058
Total transferred:         830777305 bytes HTML transferred:          813574072 bytes Requests per second:       5171.81 [#/sec] (mean)
Time per request:          28.810 [ms] (mean)
Time per request:          0.193 [ms] (mean, across all concurrent
requests)
Transfer rate:             41959.15 [Kbytes/sec] received

 

Connection Times (ms)

min

mean[+/-sd] median

max

Connect:

0

1

4.0

0

49

Processing:

2

26

9.1

29

62

Waiting:

0

12

6.0

13

40

Total:

2

28

11.4

29

65

Percentage of the requests served within a certain time (ms)
  50%     29
  66%     30
  75%     31
  80%     45
  90%     47
  95%     48
  98%     48
  99%     49
 
100%     65 (longest request)

If you leave off the-kin the abcommand line, ab will not use keep-alive connections to Tomcat, which is less efficient because it must connect a new TCP socket to Tomcat to make each HTTP request. The result is that fewer requests per second will be handled, and the throughput from Tomcat to the client (ab) will be smaller (see Example 4-2).

Example 4-2. Benchmarking with ab with keep-alive connections disabled

$ ab -n 100000 -c 149 http://tomcathost:8080/
This is ApacheBench, Version 2.0.40-dev <$Revision$> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
http://www.zeustech.net/
Copyright 1997-2005 The Apache Software Foundation, http://www.apache.org/

Benchmarking tomcathost (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
Finished 100000 requests

 

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


Document Path:          /
Document Length:        8132 bytes

 

Concurrency Level:      149
Time taken for tests:   28.201570 seconds Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      831062400 bytes
HTML transferred:       814240896 bytes Requests per second:    3545.90 [#/sec] (mean)
Time per request:       42.020 [ms] (mean) Time per request:       0.282 [ms] (mean, across all concurrent
requests)
Transfer rate:          28777.97 [Kbytes/sec] received

Connection Times (ms)

min mean[+/-sd] median max
Connect: 0 18 11.3 19 70
Processing: 3 22 11.3 22 73
Waiting: 0 13 8.4 14 59
Total: 40 41 2.4 41 73

Percentage of the requests served within a certain time (ms)
  50%     41
  66%     41
  75%     42
  80%     42
  90%     43
  95%     44
  98%     46
  99%     55
 100%     73 (longest request)



 
 
>>> More BrainDump Articles          >>> More By O'Reilly Media
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

BRAINDUMP ARTICLES

- Apple Founder Steve Jobs Dies
- Steve Jobs` Era at Apple Ends
- Google's Chrome Developer Tool Updated
- Google's Chrome 6 Browser Brings Speed to th...
- New Open Source Update Fedora 13 is Released...
- Install Linux with Knoppix
- iPad Developers Flock To SDK 3.2
- Managing a Linux Wireless Access Point
- Maintaining a Linux Wireless Access Point
- Securing a Linux Wireless Access Point
- Configuring a Linux Wireless Access Point
- Building a Linux Wireless Access Point
- Migrating Oracle to PostgreSQL with Enterpri...
- Demystifying SELinux on Kernel 2.6
- Yahoo and Microsoft Create Ad Partnership

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: