Architecting ColdFusion For Scalability And High Availability Ryan Stewart Platform Evangelist
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 Tools and approaches for monitoring
Scalability High Availability Scalability - applications and architecture that will allow you to linearly add servers and take on an increasing number of users. High Availability - When stuff breaks, users don t notice
Levels of Clustering to Ensure Availability Web server clustering Round Robin DNS, Hardware, Software ColdFusion Clustering (Application Level) Clustered instances, Connector clustering, session replication Database Server Clustering Database Specific
ColdFusion Clustering simple example Create ColdFusion instances Cluster the instances Enable J2EE Sessions Connect your web server to the cluster Deploy your application Single Server Example Test Web server Cluster CF Instance 1 connector CF Instance 2
ColdFusion Clustering creating instances ColdFusion J2EE installation is needed Using the cfusion instance on port 8300 create your instances
ColdFusion Clustering managing instances Create instance on the same server Register remote instances
ColdFusion Clustering creating cluster Cluster the Instances Enable J2EE Sessions
ColdFusion Clustering sessions After enabling session replication you will need to enable J2EE session variables within the ColdFusion admin. Uses jsessionid in addition to CFID and CFTOKEN
ColdFusion Clustering connector clustering 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)
ColdFusion Clustering connecting the web server JRun web server connector clustering Use wsconfig to connect your webserver to the cluster
ColdFusion Clustering Testing Test sticky sessions Test failover Test session replication Identify which server is fulfilling your request <cfif not isdefined("application.jruninstancename")> <cfobject action="create" type="java" class="jrunx.kernel.jrun" name="jr"> <cfset application.jruninstancename = jr.getservername()> </cfif>
Web Server Clustering - Overview 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 roundrobin DNS or a hardware device Failover is used to protect against web server failures, implemented using a hardware or software solution Web Server Clustering Web Server B Web J2EE Container Server CF Server B Web J2EE Container Server Web Server A CF Server A
Web Server Clustering - Hardware Common hardware options F5 Big IP Cisco CSS (new ver Cisco ACE) Advantages Highly scalable Support probes Disadvantages Links Cost Can be difficult to configure 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
Web Server Clustering - Software 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.
Clustering Examples 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 Round Robin DNS www1.site.com Web Server B Web CF Container Server www.site.com www2.site.com Web CF Container Server Web Server A
Clustering Examples 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 HAProxy software solution HAProxy Web Container Server Web Server B Web CF Container Server B Windows NLB software solution Web Server B NLB Web CF Container Server B Web CF Container Server A Web CF Container Server A Web Server A Web Server A
Clustering Examples 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. Hardware solution With CF clustering Web Server B Web CF Container Server B Hardware solution Without CF clustering Web Server B Web CF Container Server B CSS Web Or Container BigIP CSS Web Or Container BigIP Web CF Container Server A Web CF Container Server A Web Server A Web Server A
Improving Availability 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
Clustering in the Clouds 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
Performance Oriented Development
Scalability through Performance Oriented Development 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
Testing During Development 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
Tuning it up 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
Monitoring Performance 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 Performance Monitoring in Production CF8 Monitor See Fusion
Monitoring Servers Monitoring Production Servers ColdFusion probes Debugging & Logging -> System Probes Third party monitoring products (Nagios - open source)
Conclusion 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
Questions Questions