Steven Erat's Blog Steven Erat Photography
 
 
Viewing By Entry
 
 

TalkingTree  No Frills Guide To Clustering Multiple Instances of CFMX with Failover and Session Replication

 


I've learned how to cluster multiple instances of CFMX 6.1 on JRun4 by reading Brandon Purcell's various articles and blog entries, including how to do session replication and sticky sessions. I've found that I've had to set up various clusters from scratch from time to time, and I've put together a quick and dirty stepwise instruction set for how to configure a cluster for failover and session replication. This is a distillation of what I've learned from Brandon's more comprehenseive articles.


Setup for CFMX 6.1 JRun4 Clustered Servers (Windows)

Assumptions and warnings:
-Assumes you have CFMX 6.1 Installer and do not have JRun4 installed yet.
-Does not matter if CFMX 6.1 "Server Configuration" (Ent or Pro) already installed, except that JRun cfusion server post installation configuration wizard will install ODBC services which will 'overwrite' any existing CFMX ODBC Services, while pointing the services to the JRun server instance. To later reconfigure CFMX "Server Configuration" for ODBC Services again, edit {CFusionMX}/lib/adminconfig.xml to change this element's text value true:
-Then run the CF Admin which will present the post-install configuration wizard again.

Install option 2 for JRun4 with CFMX "cfusion" deployed
-Run CFMX 6.1 Installer
-Choose Option 2: JRun4 with CFusion Deployed
-When the JRun server "cfusion" is started, launch the ColdFusion Administrator on that instance through the JWS port (8100).
-Complete the configuration wizard in the CFAdmin
-Enter the page "Memory Variables", check box for "Use J2EE session variables", click Apply
-Stop the cfusion server instance from the Services
Save cfusion-ear as a template for other server instances
-Find {JRun4}/servers/cfusion/cfusion-ear/
-Move CFIDE directory {JRun4}/servers/cfusion/cfusion-ear/cfusion-war/CFIDE/ to the document root for the final webserver to be configured for the cluster (later).
-Remove all class files from {JRun4}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfclasses/
-Copy cfusion-ear to a Temp directory to be used as a "template" for other CFMX Jrun server instances
-Edit the {Temp}/cfusion-ear/cfusion-war/WEB-INF/jrun-web.xml, set the element jrun-web-app/session-config/persistence-config/active to value of false.

-Save the jrun-web.xml

Workaround to enable basic session replication
-Check {JRun4}/bin/jvm.config's java.class.path. Remove two sub-paths from classpath:
1) {application.home}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/cfusion.jar
2) {application.home}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib
-Final classpath may look like:
java.class.path={application.home}/servers/lib,{application.home}/lib/jrun.jar,{application.home}/lib
-Save jvm.config
CFMX 6.1 Updater 1 required for session replication issues (for cflock and nested structures)

Create new server instances, create cluster, configure servers
-Start JMC
-If original "cfusion" server instance not needed, delete server cfusion through the JMC
-Create New Server A
-Create New Server B
-Create New Cluster 1
-Add Server A to Cluster 1
-Add Server B to Cluster 1
-Manually remove "default-ear" directory from Server A and Server B directory structure under {JRun4}/servers/{servername}/
-Copy the Temp cfusion-ear directory and contents to each server instance under {JRun4}/servers/{servername}/
-Start Servers A and B From JMC
-Edit Server A and Server B Configuration
-Click on server from the JMC Home
-Remove Flash Remoting EAR from each server instance
-Click on cfusion-ear under "Enterprise Applications"
-Click on Macromedia ColdFusion MX under "Web Applications"
-Set Context Path field to /
-Check box for Enable Session Replication (Which automatically checks Enable File-based Session Persistence)
-Add either the wildcard * to New Replication Buddy or add all OTHER cluster members to New Replication Buddy (For example, if editing Server A then add Server B name to this field)
-Click Add
-Click Apply
-Repeat for all remaining server members
-Note that when re-editing the General Settings for a server instance, if context root is set to / then it will not be displayed in the JMC. If you apply any other settings changes you must populate the Context Path field again with /
-Return to JMC Home page

Enabling Sticky Sessions
-Enable "Sticky Sessions" for cluster members if desired by editing {JRun4}/servers/{servername}/SERVER-INF/jrun.xml for each server instance
-Find the Proxy Service node in jrun.xml and add an element for Sticky Sessions with value of TRUE.
-Save each jrun.xml

Configure Web Server for cluster
-Configure Web Server for cluster by running wsconfig GUI from {JRun4}/bin/wsconfig.exe
-Click Add
-Select JRun Host
-Select JRun Server, choose Cluster 1 name
-Choose Web Server to configure
-Choose Web Site to configure
-Check box for Configure web server for ColdFusion MX applications
-Click OK
-Click Exit
-Stop Servers A and B from JMC

Start servers, test failover and session replication of cluster
-Open a console or terminal window for each server instance
-Change directory to {JRun4}/bin in each console
-From each console, start one of the cluster members, for example: jrun -start CFUSION_1
-Test the cluster through requests to the configured webserver
-Can use session_test for failover and session replication test which writes session and server data to the console of the active server and to the browser for the request
-This example tests for two known issues that are fixed in CFMX 6.1 Updater 1, one for CFLOCK in session replication, and the other for nested structures in session replication
-Unzip test into web server document root
-To run test, open two browsers and request http://{servername:port}/session_test/index.cfm in each one
-Each browser is likely mapped to a different server instance, and when refreshing each test page it sticks to its own console
-Click on "create nested structure", click back on index page, refresh index page several times
-Note how one browser has a specific session id and that it was a New Session on the first hit but not thereafter.
-Test session replication and failover by killing one server instance with a CTRL-C in the console window
-Make a request to the browser that mapped to that server instance
-Note how the browser is now mapped to the other console and New Session is NO
-Click back to view the nested structure, click back to the index page, refresh a few times
-Start the server that was killed
-Make requests again to both browsers
-Note how the browser that had the session failed over is now mapped back to the first console
-When test is satisfied, stop servers from console, remove test application

Follow-up
-Configure Jrun servers to be a Service if desired
-Secure the ColdFusion Administrator if this server to be in production
-Reconfigure ODBC Services for CFMX "server configuration" (a.k.a. standalone) if present and desired.
Related Resources:
Multiple Instances of CFMX
Clustering CFMX on J2EE
Brandon's Blog on Sticky Sessions
Manually Installing CFMX ODBC Services
TechNote on Known Issue with -server JVM Arg
CFMX For JRun Metrics Logging
Configuring Individual JVM Settings for each JRun Server

 


Comments

Steve,
It's worth mentioning that although the JRun docs say otherwise, Sticky Sessions are enabled, not disabled, by default. The node is more important to be aware of if a developer wants to turn Stick Sessions off (false). It may also be worth mentioning that anything that doesn't implement the Java Serializable class 9such as ColdFusion Component Instances) will not persist across servers in a cluster and will break session memory replication altogether. Developers who's applications do this (persist CFC instances in the session scope) should look at the facade pattern for a work around - everyone else should avoid it altogether.


Hi Simon,


Thanks for sharing your tips with everyone. Matter of fact, just yesterday I was working with a customer report of session replication not working. It turned out that he had and instance of a CFC in the session scope, and that was the problem. Flat keys and nested structures in the session scope replicate just fine.


As far as the StickySessions, I usually prefer to explicitly adding that attribute/value to the JRunProxyService node for each server just so that I can know for sure what is being used rather than relying on the default which I often forget.


-Steve




Problem is this, when you remove those lines from the JVM class path, you lose VERITY and CFX support.
I dont get how you maintain verity and CFX with session replication.
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/instal17.htm


Chris,


You might be confusing the JVM library path with the JVM class path. Verity binaries are in the library path, and there's no need to change that for CFMX session replication on JRun. And C++ CFX tags are registered by adding the exact location of the CFX tag to the CF Admin, and ColdFusion interfaces with the CFX through a binary in the JVM library path. The recommended changes to the class path are necessary for session replication to work in clusters of CFMX on JRun.



-Steve


I've followed the instructions here and have tried using the session test application to test the setup. When I stop the server that the session is sticking to the mydata field of session isn't replicated properly. Instead I get

object of coldfusion.runtime.SessionScope$SerializationProblem

Any ideas what whould be causing this?


Should probably mention that the JRun server has had updater 6 applied to it and that no error messages appear in any of the logs.


Ian, I referred to two bugs in CFMX 6.1 in the above guide, which were fixed in CFMX 6.1 Updater 1. The test is designed to confirm if the fixes are working or not. Even though you upgraded JRun, the fix for that particular issue (53913) is in CF not JRun.

You should install Updater 1 for CFMX 6.1 or CFMX 7.x since these releases include the patch. The 6.1 U1 release notes mention this fix.

http://www.macromedia.com/support/documentation/en...


Is it possible to register a Web Service on a multi-instance CF 6 environment? I can register this particular WS fine locally (CF 6), and I can retrieve the WSDL on the live environment, but CF always bombs out when I go in the admin and try to register it. Here are the error details:

java.net.ConnectException: Connection timed out: connect


I am using this test application to verify our cluster is working and failing over correctly. The failover works correctly in Firefox, Chrome, and Safari, however I cannot get IE8 to maintain a session at all.

IE shows a new session on every page load. It does not maintain on a single server (sticky sessions) as the other browsers do (until an instance is brough offline to test failover)

Any ideas on this? I have tried it on a couple of IE machines with the same results.


 

 

Calendar

 
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Search This Site

 
This is an exact search only

About This Site

 
Adobe Alumni & Community Professional. Expert in ColdFusion, Flex, LCDS, Photoshop, Lightroom. Linux RHCE. Follow Me!. For my photography check out Boston Portrait Photographer.
More about me

Recent Entries

 
ColdFusion 9.01 Server Monito..

Recent Comments

 
Posted By Swagat:
Ben Forta, best-selling ColdFusion author is coming to India this August at India's largest Adobe Flash Platform Conference. Ben Forta will conduct a ...

Posted By Steve:
The updated presentation I gave at CF.Objective() 2010 is available here: [link] At the end of the preso I gave a brief, pre-recorded demo of wri ...

Posted By Brad Munz:
I've come across a OOM problem in HotSpot which looks alot like this: java.lang.OutOfMemoryError: requested 4096000 bytes for GrET in /BUILD_AREA/jdk6 ...

recently played

 

no song is playing

now playing, a plug-in for itunes

Categories

 
RSS Adobe (34)
RSS Bicycling (9)
RSS Blogging (39)
RSS Books (13)
RSS Breeze (13)
RSS CFMX Podcasts (10)
RSS ColdFusion (429)
RSS Computer Technology (51)
RSS Events (26)
RSS Flex (20)
RSS Gadgets (10)
RSS HiTech Industry (16)
RSS Java (25)
RSS Learning (57)
RSS Linux (70)
RSS Mac OS X (22)
RSS Macromedia (27)
RSS Meetup (35)
RSS New England (62)
RSS Odds & Ends (25)
RSS Outdoors (32)
RSS Personal (29)
RSS Photos (111)
RSS Photoshop (29)
RSS Podcasts (18)
RSS Rants (19)
RSS Restaurants (8)
RSS Science (34)
RSS Spain (16)
RSS Travel (42)
RSS Twitter (10)
RSS Video (20)
RSS Webcam (3)
RSS Writing (10)

Blogs I Read

 
Terrence Ryan
Ben Forta
Ray Camden
Kinky Solutions
Dan Vega
Gary Gilbert
Simeon Bateman
Red Hat Blogs
O'Reilly Digital Media
O'Reilly Radar
John Nack
The Strobist
Scott Kelby
Matt Kloskowski
Joe McNally
Digital Photography School
Engadget
Science Blog

RSS

 


Add to Google
Add to My Yahoo!

Aggregated By

 


Aggregated by ColdFusionBlogger.org

Credits and Stuff

 
BlogCFC - Free ColdFusion Powered Blog Software
CJM Group - ColdFusion Website Hosting


 
 
blog | photos | flickr | referers | webcam | stats | about | contact
 
Copyright © 2010 Steven Erat. All rights reserved.
This is a personal weblog. The opinions expressed here represent my own and not those of my employer