Tomcat throughput (a stupid test)

This week, a colleague of mine had asked me what is the maximal throughput in Tomcat. That he just needs to accept an HTTP request and log the request body. That's all. How many requests will be handled by Tomcat?

Now stop for a minute and make your guess. Is it
a) 1
b) 10
c) 100
d) 1,000
e) 10,000
f) 100,000

Well, the right answer is that it depends. It depends on your CPU, hard drive, network connection, request size, number of concurrent connections, day of the week and other important factors.

Ok, so I will tell you that I am testing it on an old Lenovo laptop with Intel® Core™2 Duo Processor T8100, 4gigs of RAM and 7200rpm disc, running Linux Mint 11 64bit, Java 6 and Tomcat 7. No performance tuning whatsoever.

I am generating the load from the same machine using JMeter with 50 threads that send requests one after another without any sleep. Each thread sends 20,000 messages containg string "Test ${counter}" where counter goes from 1 to 500,000. Yes, I know that doing tests like this is stupid. Having the test client on the same machine is just wrong. To make it even more stupid, I am writing this article while running the test. On the same old machine, of course.

The data are read from the request reader, stored in a String and sent to Logback to be logged in a file. Nothing fancy. Yes, and I restart the JVM before each test. Another stupid thing. Now you have all the information you need. Make your guess, please.

It turns out that at the and Tomcat is processing ~5,000 request/second. JIT needs some time before it optimizes the code. If I re-execute the test without JVM restart, it gets to ~5,200 requests per second and it does not climb any further. Nice performance. 5,000 request per second.

In my configuration the bottleneck is clearly the CPU. Well, it's not surprising, JMeter eats half of it. I have also tried to run the test on a MacBook Pro with 8 cores and SSD drive. The throughput is around 22,000 requests per second. Yes, more the 20k requests even in such silly test. On the Mac, JMeter consumes more CPU than Tomcat.

As I have already admitted, my test setup is just wrong. If you want, you may make it better. The source code and the JMeter test are here. It's just one servlet and few implementation classes, each for different logging strategy (direct, null and using a queue). Feel free to take, change, deploy and test it as you wish. I will be glad to see your results.

Comments are closed.