A Simple Exercise in Scalability

By , 30 April 2008

A Simple Exercise in Scalability

All our customers at Sunburnt are running the same apps from the same codebase which makes life so much easier, but also presents lots of opportunity for scaling up. Here's a few different ways we've deployed these Java webapps:

  1. Multiple contexts with the same docbase (MM). Each site runs the same code and provides their custom configuration using environment variables. Classes and libraries are deployed in the standard WEB-INF/classes and WEB-INF/lib directories.
  2. Multiple contexts with a shared classloader (MS). This is the same as above, except classes and libraries are deployed to the webapp's shared classloader (${catalina.home/lib} on Tomcat 6.0). It means each context doesn't need to load the classes anew.
  3. Single context with a single classloader (SS). Since our apps were always intended to be run in a multisites configuration, it wasn't too difficult to rewrite the key classes so that all deployments can run in a single context. It's actually the same application, but to the customers they look quite different thanks to our configuration framework.

So, how does each of these methods scale? Here are the rough performance figures for a deployment of 35 sites.

A Simple Exercise in Scalability
  MM MS SS
Startup time 90 s 60 s 4 s
Startup heap usage 50 MB 45 MB 8 MB
Running heap usage 90 MB 75 MB 35 MB
Running nonheap usage 198 MB 42 MB 42 MB

Most of that startup time goes into loading JSF servlets. Going from 35 servlets to one makes startup almost negligable. All that nonheap memory is just classes loaded into the PermGen space. Using a single classloader makes a big difference and is a pretty simple thing to do.

We've found there are similar order of magnitude performance improvements to be made by configuring OpenJPA - particularly in relation to caching, and we're now moving from one EntityManagerFactory per site to one EntityManagerFactory per context (these factories do a lot of caching).

About Roger Keays

A Simple Exercise in Scalability

I guess I'd call myself a problem solver. Either that, or I'm some sort of organic machine designed to convert oxygen into carbon dioxide. You could go either way on that. I'm into languages and stuff. I wrote a book. It's okay, I guess. What else? I like reading, swimming, eating, and playing music. Satisfied? Sheesh.

Leave a Comment

Please visit https://rogerkeays.com/blog/a-simple-exercise-in-scalability to add your comments.