Is Tomcat 4 slower than Tomcat 3? I've recently tried to port my Tomcat 3.3 webapp to Tomcat 4.1. It's the same webapp, the config files are as similar as I can make them, we're using the same connector to Apache. However, Tomcat 4.1 chews up CPU like you wouldn't believe.
Example: at peak load, one of our Tomcat 3.3 servers served 20,000 page impressions in an hour, at an average %usr CPU of 60%. Using Tomcat 4.1, we can only serve about 7,000 pages if we down-weight it so that it is at 60%. Old setup: Apache 1.3.x -> AJP 1.3 -> Tomcat 3.3.x -> webapp (uses Velocity 1.2 & Turbine 2.1) New setup: Apache 1.3.x -> AJP 1.3 -> Tomcat 4.1.x -> webapp (uses Velocity 1.2 & Turbine 2.1) We have tried profiling the app using hprof and these are the results: Method Tomcat 3 Tomcat 4 java.net.URLEncoder.encode 33.62% 22.60% java.net.SocketInputStream.read 14.15% 18.77% java.net.SocketOutputStream.write 1.87% 3.47% The encode method is used by Velocity and Turbine to generate URL links. For this particular test, T4.1 used about 1.5 times the CPU that T3.3 used. Given that the same number of pages & therefore links are being generated, I think this shows that T4.1 is spending significantly more time in SocketInputStream.read that T3.3. I have tried to following tuning options, even though they weren't needed in T3.3: - Removed servlet filters (no effect; not used in T3.3) - Reduced logging to bare minimum (no effect) - Experimented with numerous JVM settings: -server -d64 -Xmn256mb -Xmx384mb -Xconcurrentio (no effect) - Tried latest Solaris patches (no effect) - Tried 64-bit java (no effect) - Changed maxProcessor (# of threads) from default to 20 to 50 to 100 etc (no effect) - Changed Java/Solaris threading libraries (no effect) I don't have any more ideas how to fix it; instead I am clutching at straws :o) Some of those straws include: - Tuning/hacking/fixing Turbine, in case it is incompatible with the Servlet 2.3 spec. - Trying even more JVM setting permutations, in the hope that I come across the "magic" combination. - Disabling socket keepalive in Apache. Until we can fix this, we are sticking with Tomcat 3.3, which has so far been stable, fast and robust (except for allowing sessions between https and http). Chris Agmen-Smith ________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs service. ________________________________________________________________________
