Tuning the JVM
One of the great things about ColdFusion is that it runs on a JVM and as such means that it has a whole bunch of options we can use to tune it to increase performance. The bad thing about ColdFusion is that it runs on a JVM and as such means that it has a whole bunch of options we can use to bring your server to it's knees!
I'm no expert on tuning the JVM, but I have learnt a few things in the past week, which I thought I'd share. After upgrading from ColdFusion 8 Standard (running 32bit) to ColdFusion 9 Standard (running 64bit) one server was constantly showing in the application log (you do check you Coldfusion logs don't you?) the "PermGen space" error. The default install options for ColdFusion aren't great; sure ColdFusion will run but I doubt it is running efficiently.
I did a bit of googling and found some interesting posts relating to ColdFusion:
- http://blog.alagad.com/2008/01/27/don-t-throw-coldfusion-out-we-can-help/
- http://www.petefreitag.com/item/139.cfm
Also the SUN website has some good information:
- http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp
- http://java.sun.com/docs/hotspot/HotSpotFAQ.html
- http://java.sun.com/docs/books/performance/index.html
Every server will need different JVM settings and the experts will tell you to tweak, load test and try again until you find the optimal setting. This is all good advice, however, many of us have webservers in a production environment that host multiple applications (yes, I know, ideally clients should pay more bucks and have a Virtual Machine!). So, for me, these were some good starting points to bringing the server back to life (and I stress, every server is different!):
- - 64bit JVM uses approximately 30% more memory than 32bit JVM, so increase the -Xmx setting you had for ColdFusion 8 (in 64Mb blocks)
- - Increase the -XX:MaxPermSize setting, particularly if you are getting the dreaded "PermGen space" issue
- - If you have lots of transient variables, add the -XX:+AggressiveHeap setting (this one setting made the most difference for the server I was tuning)
Also, something I've seen a lot of people recommending is to set the -Xms and -Xmx to the same value as it increases predictability. Whilst this is true, what they don't tell you is that if you get it wrong the virtual machine can't compensate if you make a poor choice. So you may want to consider setting the -Xms to less then the -Xmx as a starting point, and then once things are running well, set them to the same value.
Another good article is this one: http://java.sun.com/docs/hotspot/gc1.4.2/, however, bare in mind that this is for 1.4.2 and ColdFusion 9 ships with 1.6.0.
I also recommend monitoring your servers performance using Fusion Reactor or SeeFusion. Both are relatively cheap, especially if you consider the amount of time that you may need to spend tuning your server and also the upset clients when your server slows down or worse dies.
The last thing that I have learnt, is that hindsight is a wonderful thing! What I should have done is got an expert in to tune the server before it had performance issues. This is a hard case to make internally as you're asking for money to solve a problem that doesn't exist... yet!
As I say, I'm no expert on JVM settings, and the settings I've mentioned above may not work for you. I'd love to hear if anyone else has some top tips as I'm sure I can squeeze some more performance out of our server!
- Posted in:
- ColdFusion


Comment by Big Mad Kev – July 26, 2010
To following on from Kev's comment Mike Brunt's blog (www.cfwhisperer.com) contains some good reading on this subject.
Comment by Gary Boyle – July 26, 2010
Comment by John Whish – July 26, 2010