Running two Grails sites in one Tomcat
So this Monday we had to launch a new website with Grails 1.0.2 to a site with an existing Gails 0.5.6 application running inside a single Tomcat instance.
We had the box’s ram upgraded from 1GB to 2GB to cover the anticipated extra drain - the existing app had seemingly needed 1GB for itself.
So the RAM or the extra CPU load was making the box croak and was showing up a Linux kernel 2.6.9 bug related to unlock_kernel() calls and we were getting up times of circa 50 minutes before the thing locked and needed a reboot. Also possible the RAM was faulty and the hosting company swapped it out for us pronto.
Anyway… when it was working many pages would come back blank. Logs showed OutOfMemory errors and we played with Tomcat heap settings as the problems were native thread allocation. Then the alarm bell in my head rang and reminded me that Java gives this OOM error not just for memory exhaustion but also not being able to allocate a new native thread.
Our sys admin looked into it and found that ulimit was 100 processes, a leftover from when I hacked the box to be secure with Bastille. The limit was removed - after all we need hundreds of threads in the Java VM for any level of traffic with 2 apps running.
Bingo - server runs beautifully with both apps withing 1GB Java heap. It runs better than it ever did with the single app and the hosed ulimit. Duh.
May 12th, 2008 at 7:49 am
What versions are you running, are you running apache httpd at all, and do you see any avergae heap allocation growth over time (where number of concurrent users isn’t the only factor?)
Does this look like it will run for 2 months without a hitch under a high load?
Cheers
May 19th, 2008 at 11:31 am
Apache Tomcat/5.5.20 - fronted by Apache with mod_proxy and serving the static image content etc.
2 months uptime - should be much better than that.
High load - one man’s high is another man’s low so i can’t comment. You may experience heap/concurrency problems under high load just like any other Tomcat Java web application.