|
After registering a remote server, you can create
new instances on the remote server and administer
the settings for all servers from one JMC.
 |
| Figure 4. View
of all servers that are available from within
the JMC. |
- Install ColdFusion MX for J2EE on each server
in the cluster using the WAR deployment option.
The installer will install to a temporary location.
In the next step, you will take the installed
files and deploy them onto JRun. Choose a context
root other than /. For this example, I used /cfusion.
- Deploy the WAR file to each JRun server in
the cluster.
- Locate the cfusion.war file that the ColdFusion
MX for J2EE installer created.
- Create a /cfusion folder for each server
root in the cluster.
({jrun-root}/servers/cfmxjrun1/cfusion, {jrun-root}/servers/cfmxjrun2/cfusion,
and so forth).
- Copy the cfusion.war file to each /cfusion
folder you created in step b.
- Use either Winzip or JAR to extract this
WAR file to the /cfusion folder
(for example: c:\JRun4\servers\cfmxjrun1\cfusion>jar xvf cfusion.war).
- After extracting, the folder should contain
the following folders: CFIDE, META-INF, and
WEB-INF. It should also contain several html
and cfm files.
- Delete cfusion.war from the /cfusion folder.
- Start all JRun instances that will be part
of the cluster.
- Using the built-in JRun webserver, open a
web browser to walk through the ColdFusion MX
for J2EE configuration wizard at: http://server:port/contextroot.
For this example, you must configure each of
the four servers in the cluster:
http://localhost:8101/cfusion, http://localhost:8102/cfusion, http://192.168.1.71:8101/cfusion,
and http://192.168.1.71:8102/cfusion. Use the following steps for each
server:
- Enter the serial number.
- Do not enable RDS.
- Install the JDBC services if you need them.
- Do not install the example applications
on a production server.
- If the ColdFusion Administrator appears
after completing the wizard, your ColdFusion
install was successful.
- Log into the ColdFusion Administrator. Click
the Memory Variables link under the Server Settings
section.
- Check the box for Use J2EE Session Variables
and click Submit Changes.
- Repeat steps 6 and 7 for all servers that
you will cluster.
- To create the cluster, go into the JMC and
click Create New Cluster. Add the appropriate
servers to the cluster. Enter a name for the
cluster, and choose the servers that will be
a part of the cluster.
|

|
Figure 5. Creating
a Cluster in the JRun JMC.
|
 |
Figure 6. Selecting
servers that will be a part of the JRun cluster.
|
- If the application uses session variables,
you can configure session replication to synchronize
session state across the cluster for failover.
The following procedure explains how to configure
session replication.
- Within the JMC, expand the clustername in
the left frame.
- Click on one of the servers in the cluster.
- In the right frame, click the ColdFusion
MX application.
- Click the checkbox for Enable Session Replication.
- Add the * to the New Replication Buddy and
click Add.
- Click Apply.
- Open the {jrun-root}\servers\{server-name}\cfmx\WEB-INF\jrun-web.xml
and modify the
<persistence-config> entry
to false, as follows:
<persistence-config><active>false</active></persistence-config>
- Perform steps 9-1 through 9-8 for all servers
in the cluster.
- In the JMC, restart all servers in the cluster.
- To connect your web server to the cluster,
run the Web Server Configuration tool, as follows:
- For the installer to modify the application
appropriate XML configuration files, all
clustered servers must be running.
- If you have JRun servers on multiple
computers, do not choose the default JRun
host or localhost; instead use the host
name of one of the servers in the cluster.
- Select the cluster name from the JRun
Server properties pop-up menu.
- Select the appropriate web server.
- Select the site or Configuration Directory.
- Click OK.
The installer makes all configuration
changes and restarts the web server.
 |
| Figure 7. GUI
based JRun webserver configuration tool. |
You can use the command-line webserver
configuration tool to install the webserver
connector in an environment where a
GUI is not available. For syntax details,
refer to the ColdFusion
documentation. The following example
shows one way to configure Apache in
a Unix environment:
java -jar /opt/jrun4/lib/wsconfig.jar -host
10.1.1.1 -cluster ClusterName -ws Apache -dir /etc/httpd/conf -v
|
- Copy your ColdFusion Application to the ColdFusion
application root of every server in the cluster
({jrun-root}/servers/{servername}/cfusion/).
Create data sources, mappings, and
any other settings to the ColdFusion
Administrator for every server in
the cluster. To simplify this process,
you can deploy to one server and
create a ColdFusion archive and deploy
it to the rest of the servers in
the cluster. See the section later
in this article on deploying ColdFusion
CAR files.
- Test your cluster. Browse a ColdFusion page
through the external webserver (such as
http://server/cfusion/mypage.cfm)
If you have an application that uses session
variables, you can shut the server down after
invoking a page and redirect your request to
another running server; all while preserving
the session data. To find out which server handles
your request, you can add the following code,
which displays the JRun servername.
<cfobject action="create" type="java" class="jrunx.kernel.JRun" name="jr">
<cfset servername = jr.getServerName()>
<cfoutput>#servername#</cfouput>
The process routes all incoming requests through
the external webserver in a round-robin fashion
across all JRun servers in the cluster. In addition,
the process assigns all subsequent incoming requests
a jsessionid for session tracking directs them
to the same JRun server by using sticky sessions.
Application Considerations for ColdFusion
MX Clusters:
Take the following into consideration when creating ColdFusion MX Clusters:
Consider the overhead when replicating
session data. An unclustered ColdFusion
instance does not limit a developer to the amount
of data that can be stored in the session scope.
In a cluster, using in-memory session replication
the session data for a particular user must be
replicated each time it is modified. If you store
a significant amount of information in the session
scope, it can degrade performance. There is no
official rule to the amount that the session scope
can store, but consider it when you are developing
the application. If you plan to store a significant
amount of information in the session scope, perform
load testing within a cluster to ensure stability
and performance.
You cannot cluster session-based persistent
ColdFusion Components. You cannot store
ColdFusion components in the session scope when
using clustering and session failover. Currently
ColdFusion MX does not support serialization
of CFCs; therefore, you cannot replicate their
state across a ColdFusion MX cluster. The following
code demonstrates storing an instance of a components
in the session scope.
<cfset session.securitycomp=CreateObject("component","directory.componentname")>
This code will work until a server within the
cluster fails. When a server fails and incoming
requests fail over to another server, the server
will lose the session scope stored in the CFC and
throw errors to the logs.
Separate static and dynamic content to
improve performance. With ColdFusion
MX for J2EE, all requests to the webserver to
http://server/cfusion (context root) will go to
JRun regardless of the extension (.cfm, .htm,
.gif, .jpg). If images and static content exist
in /cfusion, all static content will go to the
JRun connector back to the webserver. This defeats
the purpose of high-performance caching built
into the web server. Therefore, we recommend that
you place all static content in a folder outside
of the /cfusion folder within the webserver root.
For example, put all html in a /html folder and
place all images underneath the web server root.
In a site with a significant amount of static
content you will see a significant improvement
in throughput and pages/sec by separating the
content; in some cases, the performance improves
200-300%.
Using CAR files to simplify deploying clusters.
ColdFusion MX can archive and deploy
applications into a ColdFusion Archive CAR file.
The Archives and Deployment page includes tools
that let you archive and deploy ColdFusion applications,
configuration settings, data source information,
and other types of information to back up your
files quickly and easily. The complete list of
archived information includes the following: Name
and file location, Server settings, ColdFusion
mappings, Data sources, Verity collections, Scheduled
tasks, Java applets, and CFX tags. After archiving
an application and all of its settings, you can
easily deploy the application across a cluster
of ColdFusion MX servers, easing the administrative
overhead of configuring each setting on every
server.
Sample cluster configurations
The following sample cluster configurations will help you plan your strategy.
Configuration 1: One webserver
and two ColdFusion MX for J2EE servers (a single
machine for session failover).
Using a single server, ColdFusion MX for J2EE
administrators can create multiple instances of
ColdFusion on a single machine, thereby reducing
the chances of a single application causing complete
server failure. You can cluster multiple instances
together to act as one instance with in-memory
replication of session data enabling session failover.
Figure 8 shows a configuration that provides load
balancing and failover on the application server
using the connector clustering. It provides session
failover when a JRun instance fails, but does not
provide failover if the web server fails.
 |
| Figure 8. Sample
Configuration 1: One webserver for two ColdFusion
MX for J2EE servers (a single machine for session
failover). |
Configuration 2: Two web servers
(ClusterCATS) and two ColdFusion MX for J2EE servers
This configuration provides load-balancing and
failover for the web server and application server.
Load-balancing on the web server uses round-robin
DNS. Macromedia ClusterCATS, available with JRun
4.0 as a separate download, provides failover capabilities.
Load-balancing and failover on the application
server uses connector clustering in JRun. See figure
9.
 |
| Figure 9.
Sample Configuration 2: Two web servers (ClusterCATS)
and two ColdFusion MX for J2EE servers. |
Configuration 3: Hardware load
Balancing, two web server, and two ColdFusion
MX for J2EE servers
This configuration provides load-balancing and
failover on the web server and application server.
A hardware-based device provides load-balancing
and failover. There are several options for hardware-based
load balancing; a few examples are Cisco Local
Director, CSS, F5 BigIP, Nortel ACEDirector, and
Foundry Networks ServerIron XL. You create load-balancing
and failover for the application through JRun connector
clustering.
 |
| Figure 10. Sample
Configuration 3. |
ColdFusion MX for J2EE may seem challenging at
first, but once you become familiar with JRun and
the configuration details of ColdFusion MX for
J2EE you will find it to be much more flexible
than ColdFusion MX standalone or ColdFusion 5.
From multiple instances on a single machine to
ColdFusion MX clusters spanning multiple machines,
the configuration options are unlimited with ColdFusion
MX for J2EE.
|