MyTimetable

MyTimetable Updates

Some notes on Tomcat connector performance

Marco Krikke | Published April 7, 2012 | Updated November 28, 2021

In my last blog post, I mentioned that there is a performance difference between Tomcat’s APR and BIO / default connector. In this blog I did a quick comparison of these connectors.

Tomcat ships with 3 HTTP(s) connectors:

  • Blocking IO (org.apache.coyote.Http11Protocol): this is the default and most stable connector.
  • Non-blocking IO (org.apache.coyote.Http11NioProtocol): this is a non-blocking IO connector, which you will need for Comet/WebSockets and should offer slightly better performance in most cases.
  • APR (org.apache.coyote.Http11AprProtocol): this connector uses Apache Portable Runtime and OpenSSL instead of their Java counterparts. Because of this, performance is generally better, especially when using SSL.

To do a quick comparison of these connectors, I used ApacheBench and ran some simulated load tests (100k requests, 100 concurrent requests) on the various connectors. The page requested was a simple JSP that displayed the current date. Tomcat 7.0.26 ran on Windows (yeah, really, it can run on Windows), and to compare with the Apache HTTPD and PHP I also did a run on a simple PHP page displaying the current date on Apache 2.2.16 (on Linux). Tests were done using HTTP and HTTPS, with and without keep-alive. The results are by no means scientifically significant, but give a general idea on the performance differences. YMMV, so please run your own benchmarks on your own applications (and create a more intelligent test scenario, using for instance Apache JMeter).

Connector HTTP HTTP KEEP-ALIVE HTTPS HTTPS KEEP-ALIVE
BIO 7341 14809 142 4036
NIO 3816 10257
APR 8214 15062 240 11121
Apache HTTPD 8780 15880 236 4056

 

Numbers are in request per second, higher is better. Due to some ApacheBench bug I could not test NIO over HTTPS. Some conclusions we can draw from these results:

  • Apache Tomcat performs on a level comparable to Apache HTTPD. This is at least the case for dynamic requests, but I have seen similar results for static requests.
  • When using SSL: use keep-alive, unless you have a specific reason not to.
  • When using SSL on Tomcat: use APR.
  • Don’t expect NIO to give a better performance than BIO out of the box. Benchmark, benchmark, benchmark.
© Copyright - SEMESTRY 2023 All Rights Reserved.