An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

ColdFusion in the Cloud (and clustering)

December 13, 2008 · 2 Comments

This week has seen my focus shift back from ActionScript / Groovy to ColdFusion, although not specifically programming in CFML. A couple of blogs have been buzzing about the pros and cons (and plain ol' whys) of running ColdFusion in the cloud, such as on Amazon's EC2 service. Obviously you can run Open BlueDragon or Railo without worrying about cost but for many people, only Adobe ColdFusion will really do what they need and the current EULA does not really accommodate that (partly because the "per 2 CPU" aspect doesn't cover the Amazon situation where you simply don't know how many physical CPUs you actually have!).Adobe are very aware of this and Adam Lehman jumped into the discussion on Jeffry Houser's blog to point out that Adobe is "not actively trying to prevent/charge anyone" who runs ColdFusion on EC2 and that he wants "to chat with you about how we [Adobe] might make the EULA more "cloud friendly" for Centaur (aka CF9)." We already use virtualization in-house for development and staging instances - we run ten VMs on one big server, each with ColdFusion Enterprise, all covered by one license since the machine is a dual 4-core CPU box. As many of you know we run Broadchoice Workspace on EC2 already but we haven't yet tried to run production ColdFusion infrastructure on EC2. This week (after discussions with Adobe a while back) I got the chance to build out a cluster of ColdFusion instances on EC2, using ActiveMQ to synchronize the Transfer ORM cache between them, much as we do with our existing ColdFusion-powered CMS (our "2.0" Workshop product which we built and launched earlier in the year). ColdFusion runs perfectly on EC2, as you might expect, although my feeling is that disk access is noticeably slower than a dedicated machine and that affects application startup time (it feels a little slower than our in-house setup using Xen, even tho' that seems to be what Amazon use). The real experiment for me tho' was to get a full cluster operational. Our current production infrastructure works much like, in that it has a hardware load balancer in front of several separate instances of ColdFusion (which happen to be on separate machines). For my EC2 setup, I wanted multiple instances on a single EC2 "server" using JRun clustering to provide application server redundancy with a single web server (Apache). It's been a long time since I've worked with the JRun connector in anything but the most basic configuration. Back at Macromedia, I had some bad experiences with the connector which led us to use a hardware load balancer and to have Apache simply proxy to the JRun Web Server instead of using the connector. CFMX 6.0 Updater 3 included hundreds of bug fixes which allowed us to launch on ColdFusion in March 2003, and the JRun connector was on the receiving end of many of those bug fixes. Once I had a configured instance of CF8 up and running, connected to Apache, on EC2, I used the Instance Manager to create two new instances to use as the clustered pair (the master instance contains the Instance / Cluster Manager pages in the CF Admin but created instances do not). I was a bit surprised that the created instances were not entirely clones. The created instances did not have any of the data sources that were defined in the original so I had to created those manually. Only the created instances can be part of a cluster so I was wondering how that would sit with the JRun connector I already had setup for the master instance. The answer was that they were not configured to talk to Apache by default so I had to edit the servers/{instance}/SERVER-INF/jrun.xml file to ensure that the JRunProxyService has <deactivated> set to false. I find this double-negative approach to settings somewhat counter-intuitive! You also have to remember to make a note of the <port> number (and change it if, like me, you don't like the default setting chosen by the instance manager). I set both instances to be activated (deactivated = false) and changed their ports to be 51001 and 51002 then I was able to edit the Apache httpd.conf file to have both instances in the JRunConfig Bootstrap parameter as, (note: comma-separated). I also made sure that the WebService service was using a port of my choosing - like the selection of the proxy ports, the instance manager automatically chooses ports that don't conflict with any other instances (such as admin or samples - or the original cfusion instance). It took me a while to get each instance set with the ports I wanted (I needed to move cfusion off its default ports so it involved stopping and starting each instance several times and running the Instance Manager to modify settings). A couple of times, an instance did not restart when modified so I had to restart them manually. Not a big deal but an annoying and inconsistent behavior. I configured the cluster to use round-robin and sticky sessions - but not session replication (since this does not work particularly well - don't get me started!). Once I had the cluster up and running with Apache, I tested that access via multiple browsers directed traffic to one instance and then the other. I also tested that if I stopped an instance, requests automatically failed over the other instance (we use an encrypted cookie to identify a user session and reconstruct the server-side data if it is missing, thus allowing full session failover). Satisfied that was working, I tried to access the CF Admin on the master instance now it was not connected to Apache. Much to my surprise, it failed because it couldn't find the files. I puzzled over this for a while before remembering that when I had installed CF8 originally, I had placed the webroot outside of the installation tree. For the newly created instances, CFIDE had been copied into the webroot so the CF Admin was accessible. Again, I was a bit surprised that the newly created instances were not exact clones. In order to fix the master instance, I had to edit WEB-INF/jrun-web.xml to add a <virtual-mapping> from the <resource-path> /CFIDE/* to the <system-path> where my actual CF Admin was installed. It took a lot longer than I expected but I finally had three instances of ColdFusion running on EC2, two of them clustered and connected to Apache and one the "master" instance which I could shutdown when it wasn't needed. I have a lot more testing to do but the basics seem to be working pretty well - after all that effort. What are your experiences of clustering ColdFusion?

Tags: adobe · broadchoice · coldfusion · hosted · openbd · railo · saas

2 responses so far ↓

  • 1 Matthew Williams // Jun 23, 2009 at 12:28 PM

    I realize I'm a bit late to the party.. but do you have any documentation on how to use a proxy to connect ColdFusion/JRun to Apache instead of the JRun connector? I'm running into issues where the connector just dies. It's becoming problematic enough that the higher ups are taking notice and have requested a resolution. Moving away from the connector is something I'd like to try, but I've never come across information detail how it's done.
  • 2 Sean Corfield // Jun 23, 2009 at 2:26 PM

    @Matthew, see the Apache docs:

    This requires the JRun Web Server which is not intended for production use (despite the fact that and have run like that for years!).

    Another option which may be more reliable:

    Run ColdFusion on Tomcat and use mod_proxy_ajp to connect Apache to Tomcat. That avoids the JRun web server altogether - Tomcat's a much better web server.

Leave a Comment

Leave this field empty