I am using tomcat to convert pdf to png. I was using Jmeter to load/throughput test the app using a Intel(R) Xeon(R) CPU X5550 @ 2.67GHz server which has 16 hyper-threaded cores. Tomcat6 had 2gigs of heap memory allocated, and the connector was setup to handle 1000 concurrent connections. During my load testing I discovered that as I increased users the response time degraded which is normal. The load average, however, was very low (around 1 for a 16 core machine), and cpu usage was around 60%. I was monitoring the tomcat instance with jconsole through JMX, and found that memory usage was not an issue. In order to keep the response time low, I created around 8 instances of tomcat on 8 different ports, and have a load balancer balance the load between all 8 ports during my load testing. This time I found that the server was able to handle many more concurrent connections without degraded response time. The load average was also high at 7. So, it seems like tomcat is not using the CPU efficiently when setup with only one instance (I even tried creating multiple connectors on different ports).

It seems like we need to run multiple tomcat instances on a single machine to extract the most performance. Doing this setup is not optimal since creating multiple instances on a pool of servers, and maintaining it will be a pain.

My question is that is it possible to configure tomcat such a way so that a single instance will use as much cpu as possible with a high load average?

Please comment if you have any question about the setup.

I'd appreciate any help/pointer.


It looks to me that the application has the bottleneck. I guess it use just only one thread to convert the pdfs.

Tomcat runs servlets parallel but when the servlets call a one-threaded library your web application become a one-threaded app. You have to modify your application to use more threads.

A not too nice workaround is running as many Tomcat instances as many core you have and load balancing the requests to them (as you mentioned in the question).

  • Yeah it is a single threaded application. I was hoping that tomcat would do the load balancing between threads. – Mir Sep 29 '11 at 23:06
  • I've edited my answer, check it. – palacsint Sep 29 '11 at 23:18
  • I do use jmagick for the pdf to png conversion. Jmagick uses imagemagick which uses ghosscript internally. This could be the issue since as far as I know ghostscript is single threaded. What do you think? – Mir Sep 30 '11 at 2:31
  • I've made a simple test and you're right, gs use just one thread/cpu. I'm not an imagemagick guru but maybe you should replace it to an other converter library or configure imagemagick to use more thread somehow. StackOverflow has some question about this field, take a look at them. – palacsint Sep 30 '11 at 20:27
  • 1
    thanks. I got rid of jmagick. I am using a processbuilder to call convert directly from each thread. Now I am getting much better cpu usage. – Mir Oct 1 '11 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.