®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Architecting ColdFusion For
Scalability And High Availability
Ryan Stewart
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Introduction
Architecture & Clustering Options
Design an architecture and develop applications that scale linearly across multiple servers and handles failures gracefully.
Performance Oriented Development
Getting the most out of a single server by optimizing your application code.
Performance Tuning
ColdFusion server tuning and load testing.
Monitoring
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Scalability
≠ High Availability
Scalability - applications and architecture that will allow you to linearly
add servers and take on an increasing number of users.
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Web server clustering
Round Robin DNS, Hardware, Software
ColdFusion Clustering (Application Level)
Clustered instances, Connector clustering, session replication
Database Server Clustering
Database Specific
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Create ColdFusion instances
Cluster the instances
Enable J2EE Sessions
Connect your web server to the cluster
Deploy your application
Test
ColdFusion Clustering – simple example
Single Server Example
connector
CF Instance 1
CF Instance 2
Cluster Web server
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
ColdFusion J2EE installation is needed
Using the cfusion instance on port 8300 create your instances
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Create instance on the same server
Register remote instances
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Cluster the Instances
Enable J2EE Sessions
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
After enabling session replication you will need to enable J2EE session
variables within the ColdFusion admin.
Uses jsessionid in addition to CFID and CFTOKEN
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
ColdFusion web server connector clustering
JRun Webserver Connector allows a webserver to communicate with
JRun, runs as a filter or plugin in the webserver
Cluster by connecting multiple instances of ColdFusion to a single
webserver with the JRun Webserver Configuration Tool
Load balancing and Failover built in to the connector
Connector load balancing algorithms
(round-robin, weighted round-robin, weighted random)
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
JRun web server connector clustering
Use wsconfig to connect your webserver to the cluster
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Test sticky sessions
Test failover
Test session replication
Identify which server is fulfilling your request
ColdFusion Clustering – Testing
<cfif not isdefined("application.jrunInstanceName")>
<cfobject action="create" type="java" class="jrunx.kernel.JRun" name="jr"> <cfset application.jrunInstanceName = jr.getServerName()>
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Two or more web servers that support one or more domains are
grouped together as a cluster of servers
Use Load balancing scheme to manage increases in load using
round-robin DNS or a hardware device
Failover is used to protect against web server failures, implemented
using a hardware or software solution
Web Server Clustering - Overview
Web Server A Web Server B Web Server B Web Server Clustering Web Server Clustering CF Server A CF Server B Web Container Web Container Web ContainerServerJ2EE
Web ContainerServerJ2EE
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Common hardware options
F5 Big IP
Cisco CSS (new ver Cisco ACE)
Advantages
Highly scalable
Support probes
Disadvantages
Cost
Can be difficult to configure
Links
CSS with CF -http://www.adobe.com/devnet/coldfusion/articles/css_multi.html
F5 Big IP -http://www.adobe.com/devnet/coldfusion/j2ee/articles/balancing_j2ee.html
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Windows Network Load Balancing (NLB)
HAProxy (Unix only)
http://www.37signals.com/svn/posts/1073-nuts-bolts-haproxy
Speed. It’s really, really fast.
It’s efficient. One of our instances is handling around 700 requests per second and using less than 5% CPU and only around 40MB of RAM on the Xen instance that it’s running on.
It allows us to make configuration changes gracefully, without breaking any existing connections.
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Two server cluster with DNS round robin and CF cluster
DNS Round robin handles distribution of load
ColdFusion is clustered across two servers, session replication can be
enabled or disabled depending on needs.
No web server failover but ColdFusion instances can be shutdown for
maintenance
Clustering Examples
www1.site.com Web Server A Web Server B Web Container Web Container Web ContainerServerCF Web ContainerServerCF www2.site.com Round Robin DNS www.site.com®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Two server cluster with software load balancing
NLB or software solution handles web server load balancing and failover
ColdFusion does not need to be clustered unless session replication is
needed. http://www.adobe.com/devnet/coldfusion/articles/nlb_failover.html
Clustering Examples
Web Server A Web Server B Web Container Web Container Web ContainerServer BCF Web ContainerServer ACF Windows NLB software solution NLB Web Server A Web Server B Web Container Web Container Web ContainerServer BCF Web ContainerServer ACF HAProxy software solution Web ContainerWeb ContainerHAProxyServer®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Two server cluster with hardware load balancing
Hardware solution handles web server load balancing and failover
ColdFusion does not need to be clustered unless session replication is
needed.
Clustering Examples
Web Server A Web Server B Web Container Web Container Web ContainerServer BCF Web ContainerServer ACF Hardware solution With CF clustering Web ContainerWeb Container CSS Or BigIP Web Server A Web Server B Web Container Web Container Web ContainerServer BCF Web ContainerServer ACF Hardware solution Without CF clustering Web ContainerWeb Container CSS Or BigIP®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
If a failure occurs with a cluster member what do your users
experience?
Handling user persistence across the cluster
Session replication
Creating your own persistence mechanism
Improving Availability
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Create a robust architecture in a cloud environment with the ability to
add on demand servers. Do it without purchasing a single piece of hardware.
Amazon Web services
Ec2- Elastic Computing Cloud S3 - Simple Storage Service
Third party companies make it easier to get started on the cloud
RightScale - deploy & scale applications in a turnkey architecture Stax.net - develop & deploy
Deployment
Apache with Tomcat or JBoss MySQL
Archive ColdFusion Applications as a J2EE Archive
Clustering in the Clouds
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Identifying, isolating and fixing bottlenecks during development
Load testing features or specific areas during development
Tuning Process
Measuring Performance
Focus on single user baseline performance Load test for multi user performance
What are the tunable Application Code ColdFusion settings
Application server/JVM settings Web Server/OS Settings
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Single user testing
Bottleneck testing and isolation with ColdFusion debugging GetTickCount, CFTIMER
Load Testing
Small test scripts, no wait time
Free tools available (OpenSTA, WebStress, ApacheBench) Run single user tests within your browser during load tests
Common areas to improve in your code
Database queries External Calls
Caching (content & queries) - CF_Accelerate
Testing During Development
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
ColdFusion Settings
Simultaneous thread or active handler threads
Template cache size
Query cache size
Trusted cache
Application Server settings
JVM settings
Garbage collection
OS Specific tuning
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
JRun metrics JVM Output Network Monitoring Disk IO monitoring CPU monitoring ColdFusion 8 Monitor
Third party tools
Fusion Reactor See Fusion
Database monitoring
Profile in real time and identify queries by execution time and CPU time.
Monitoring Performance
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Performance Monitoring in Production
CF8 Monitor See Fusion
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Monitoring Production Servers
ColdFusion probes – Debugging & Logging -> System Probes Third party monitoring products (Nagios - open source)
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Architecture & Clustering Options
Design an architecture and develop applications that scale linearly across multiple servers and handles failures gracefully.
Performance Oriented Development
Getting the most out of a single server by optimizing your application code.
Performance Tuning
ColdFusion server tuning and load testing.
Monitoring
Tools and approaches for monitoring
®
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Questions