July 15, 2005
Shrinking tomcat

Back in the tomcat 3.3 days, one of my pet projects was to shrink it enough to run on a Zaurus. It eventually got to 0.9M, with a startup time of about 1.1 secs on a 1GHz pentium, and about 20 secs on the zaurus. This was done by eliminating modules and code that wasn't actually needed - no Proguard obfuscation/shrinking was used, probably that would have made things even better.  The normal tomcat3.3 jars are about 1.6M.

Since Remy, Mladen and Co are taking care so well of the server side, with amazing performance improvements, I spent a bit of time to repeat this experiment on the 5.5.

First draft of tomcat5.5 mini, i.e. tomcat and all the dependencies, got to  1.6M, plus jasper at 360K - so about 2M, down from 3.3M for the 'embed' tomcat release. This is done with only minimal changes in the code, and includes logging, beanutils, modeler, digester, jsp and servlet api, and only http connector - all that's needed to run tomcat in jdk1.5 ( not included is JMX - 360K - needed to run in 1.4 ). I'm pretty sure I could skim at least 30% more, and with some obfuscation/shrinking with proguard it can get around or below 1M. Of course, no particular motivation to do this extra shrinking - all I wanted is a standalone jar I can use with "java -jar tomcat.jar" and starts quickly. Current startup time on same 1GHz machine is about 2.5 secs.

The first goal of this experiment is to get a single jar, with all defaults and minimal configuration, that you could just add to an application or run on low-end server. I don't expect to be able to run it on my home web  server, a NSLU2 device.

The second goal is to add few features to make tomcat more suitable for 'desktop' or 'personal' usage. There are 2 things, besides the simpler configuration - first, the ability to start on demand, using inetd for the first request ( and the new launchd on Mac ), so it won't use memory when nobody is using it. The other problem is to shut down automatically after a period of inactivity.

While everyone agrees that (x)inetd is not the best choice for a server, it does make a lot of sense for desktop use. Too bad apache2 no longer supports it - and even Apple doesn't seem to be using this feature, even if 99% of the time the server is just idle.

Posted by costin at July 15, 2005 09:13 PM
Comments
Disabled due to spam. Click on the link to post a comment, it'll be sent in email ( and thus usual mail spam filters and blacklist applied ). It may be made accessible later on, but code needs to be written for that. Comments