I think, therefore I blog

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
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

Roger Keays is an artist, an engineer, and a student of life. Since he left Australia in 2009, he has been living as a digital nomad in over 40 different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, and finding good food. Click here to subscribe to his weekly blog, or stalk him on Facebook and Twitter.

Leave a Comment

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

Join Over 1000 Subscribers

I write every Sunday about travel, psychology, and technology. Thousands of people just like you have already subscribed—and for good reason. It'll change your life. And it's free :)

Read a Good Book

“A spellbinding true story of love, passion and adventure. One can’t help but be swept away by 100% Love Guaranteed.” —Dr Tammie Matson, author of Elephant Dance.

Chat For A While

Your Vote Matters

Which animal will take over when humans go extinct?