A Simple Exercise in ScalabilityPosted by Roger Keays, 30 April 2008, 2:51 AM |
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:
- 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.
- 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.
- 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.
| 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).
| << Converting unsigned to signed bigints | Back to Blog | javax.naming.NameNotFoundException: Name jdbc is not bound in this Context >> |
Add a comment
Please visit http://www.ninthavenue.com.au/blog/a-simple-exercise-in-scalability to add your comments.