power for web applications. scaling cold fusion applications douglas nottage, autobytel.com
TRANSCRIPT
Power for Web Applications.Power for Web Applications.
Scaling Cold Fusion ApplicationsScaling Cold Fusion Applications
Douglas Nottage, Autobytel.comDouglas Nottage, Autobytel.com
What Does “Scaling” Mean?
Successfully “Scaling an Application” means that your web site right now is experiencing five times your normal traffic levels but the visitors to the site feel like they are on their own personal T-3 circuit.
If you are reading this and wondering if your site could survive such growth as it stands today, you are not ready to be the next Amazon.com … period.
Examples of Scalability
Autobytel.com - Super Bowls 97 & 98 Burst of 19x Traffic Levels within 30 minutes
of commercial airing.
Victoria Secret Live Broadcasts Enough said . . .
The “Toy Race of 1999” eToys, Toys ‘R Us, Amazon.com … If you’re not online, I’ll buy my toys
elsewhere.
This Presentation
Your Web Server Environment How to start small and grow
Your Application Environment Designing Applications Before they Grow
Your Database Environment Because the World Doesn’t Live on One
Application Alone
Putting it All Together . . .
The “Big Bang” - Getting Started
Management wants a web site . . . Today!
Finance wants you to use one of the “faster computers” on someone’s desk.
Finance denies $1500 for Cold Fusion. You download the30 day eval. in a panic.
SQL Server? Who has that kind of money?! In a frenzy, you whip up an Access database.
Good thing your ISP does DNS!
www.siteofthecentury.comwww.siteofthecentury.com
The “Big Bang” - Getting Started
8 am - Marketing runs commercial. 5,000 people visit in 30 minutes. IIS reports 300 current
connections. Your boss can’t get pages to
load on his browser via the 100Mbps LAN.
Your database shows only one order but 5,000 visitors.
At 10 am your boss wants a meeting.
What are you going to recommend?
www.siteofthecentury.comwww.siteofthecentury.com
X
“Puberty” - Growing Quickly
We need a faster server!
More RAM! Access is for kids . . .
Let’s upgrade to SQL Server!
Download the web logs and run WebTrends on your desktop.
Commercial #2 - Hell on Earth!
8 am - Commercial Airs 8:05 am - Server hits 300 connections. 8:10 am - Extra RAM Is Unused. Why? 8:15 am - Pages are running really slow. 8:16 am - Fearing for your job you decide
you must need two web servers. How do you get one site to go to two
different web servers?
Round Robin DNS - FREE Solution
When users ask what IP address your site is located on, the DNS server rotates among a set of addresses in a “round robin” fashion, thereby putting load on multiple servers.
Fast and easy to implement.
11 2233
44
DesktopDesktopPCPC
Faster Faster PC orPC or
ServerServer
Round Robin DNS - No Failover
Desktop PC Fails or Performs much more slowly than Faster PC
Every second visitor is sent to the “Desktop PC” and waits . . .
What are your options?
11 2233
44
DesktopDesktopPCPC
Faster Faster PC orPC or
ServerServer
Round Robin DNS - FREE Solution Re-write DNS so that
only Faster PC is in the DNS.
Using one server you are destined to crash Faster PC.
Put two Faster PC records in DNS but only one for Desktop PC to distribute load based upon capacity (2:1 Ratio).
1122
3344
DesktopDesktopPCPC
Faster Faster PC orPC or
ServerServer
Round Robin DNS - No Failover
Desktop PC Fails Again.
Every third visitor is sent to the “Desktop PC” and waits . . .
Round Robin cannot protect against failover.
What are your options? DesktopDesktop
PCPC
Faster Faster PC orPC or
ServerServer
1122
3344
Hardware Solution Hardware load
balancers like Cisco’s Local Director take ALL of your web traffic and distribute it among servers it sees are ‘alive’ and removes servers if they appear to fail.
Sometimes “dead” servers “appear” alive and receive traffic.
1122 33 44
Have a Have a second second device device
around in around in case the case the first fails.first fails.
Software Solution - Clustering Software on each
computer monitors its health and when it feels “ill”, sends traffic to another server until it feels it is up to handling a larger load.
Sets of computers configured this way are called “clusters.”
1122 33 44
Server 1 tells Server 1 tells Server 2 it is Server 2 it is
nearing nearing capacity and capacity and
starts sending starts sending users there.users there.
Server 1 is too Server 1 is too busy. User is busy. User is
“redirected” to “redirected” to Server 2Server 2
Hybrid Solution - Best Solution Load balancing
software tells the hardware “how it feels” so the hardware can decide which is the fastest server (at that instant) to send the user to.
The software knows more about the server’s “health” than the hardware does.
1122 33 44
Have a Have a second second device device
around in around in case the case the first fails.first fails.
Servers tell Servers tell the the
hardware hardware load load
balancer balancer how they how they
are are performing.performing.
After the Dust Settles . . . Company X now has
eight web servers in a cluster and users can get to the servers.
However, only one server has SQL Server on it and should it fail, the other servers will not have any data for their applications.
1122 33 44
NT/SQL Clustering Company X creates
two SQL Servers and puts them in an NT/SQL Cluster.
Should the left server fail, the second will take over and the web cluster will get its data from it until the left server is repaired and brought back online.
Web ClusterWeb Cluster
SQLSQLClusterCluster
DriveDriveArrayArray
Bandwidth Limits and Costs . . . Customers now rely
upon Company X’s web site and the T-1 line is not enough. Getting more bandwidth is costly.
Is there a cheaper way to grow until you can afford more bandwidth?
Web ClusterWeb Cluster
ConsumersConsumers
Limited BandwidthLimited Bandwidth
Big DemandBig Demand
Using Cheaper Bandwidth . . . Company X changes all
<IMG> tags to point to:images.companyx.com
ISP hosts this URL on larger web servers where bandwidth is much cheaper.
Company X uses its expensive in-house bandwidth only for creating CFML pages. Web ClusterWeb Cluster
ConsumersConsumers
Limited BandwidthLimited Bandwidthis used foris used forCold FusionCold Fusion
(Dynamic Content)(Dynamic Content)Pages OnlyPages Only
ISP’s WebISP’s WebServer w/Server w/GIFs / JPEGsGIFs / JPEGs
(Cheaper(Cheaperand largerand largercapacitycapacityfor staticfor staticcontent)content)
Deploying Code to Many Servers Copying CFML to lots of
servers can be cumbersome and time consuming.
Switch IIS to get its content from C:\ to \\SQL2\yourshare\
IIS/CF will get their code from the file share / drive array.
When you post new code it’s live for all.
Web ClusterWeb Cluster
SQLSQL#2#2
DriveDriveArrayArray
SQLSQL#1#1
CFMLCFMLPagesPagesfor IISfor IIS
DataDataforforCFCF
Creating a “Staged” Environment Company X releases a brand new site on January 1,
2000. On January 2, development starts on a brand new
version to launch several months later. How can you keep a copy of the existing code to
develop on and fix bugs with while also working on the new code?
If you can’t use the live web server to develop on, where do you code?
Where do you test code before it is published to the live web server?
eCommerceSite
Fiber Channel
Drive Array
End Users
Developers
Testing
SQL
Database
Web
Server
Development
Test TeamTest Team
Extranet
Users
SQL
Database
SQL
Database
Production
Off-Site Image / Proxy
Servers
SQL & Application NT Cluster
Extranet
Proposed System Architecture
What Servers to Buy?
As soon as possible, upgrade your data to SQL Server and give SQL its own server.
Give SQL as much power as is practical. Given two uneven servers, the more
powerful one should be your data server. Two dual CPU web servers appears to be
better than one quad CPU web server. Your case is always the exception . . .
Summing Up - Hardware
Dual CPU Web Servers - 256 Mb RAM Quad CPU SQL Servers - 512+ Mb RAM Software/Hardware Hybrid Load Balancing &
Server Clustering NT/SQL Cluster to Protect Your Data Use the Second SQL Server as a CFML File Share
to Simplify Uploading Code Use a Proxy or Web Server at your ISP to Save
Your Expensive Bandwidth Create a “Staged Environment”
Cold Fusion Administrator What are the “optimal” settings for the Cold
Fusion Administrator? Limit Simultaneous Requests To _____? Timeout Requests - 30 or 60 seconds Restart at 5 - 10 Unresponsive Requests Template Cache - How much can you spare? Cached Query Limits - ??? CFMAIL Timeout - 30 seconds (CPU Threat) Log Slow Pages - 10 seconds Assign an SA password!!!
Cold Fusion Administrator
Cold Fusion Admin - Security Risks Password protect or remove /cfdocs folder Deactivate RDS on production servers Deactivate CFREGISTRY, CFFILE and
CFDIRECTORY if you don’t use them. Deny CF Studio Access in production. Rotate CF Admin passwords regularly Don’t Do Beta … Wait Until It Is Released
Cold Fusion - Scalability Issues
Session Variables - Frequently Ineffective Caching Pages - Only for “static” pages Caching Queries - Not if excessive Server Arrays - Keep it in RAM NEVER use SELECT * Milliseconds count - Test your application P-Code Errors - Move to CF4.5 Use SQL where it performs better.
Cold Fusion - Scalability Issues
White Space Kills! - Strip it! <CFSETTING ENABLECFOUTPUTONLY=“YES”>
Scope Your Variables - form.myVar Custom Tags - Share Code & pCode Keep Calculations to a Minimum Use Stored Procedures
Faster Execution Less Data to Pass Around SQL Can Pre-Format Your Data
Cold Fusion - Scalability Issues
Application.cfm is NOT a “Cure All” Loads on EVERY Page You’re Probably Overloading It
OnRequestEnd.cfm - End of All Pages Assign an SMTP Server to Cold Fusion
Get the SMTP Traffic Off Your Server ASAP!
Schedule CFML -> HTML Page Creation via CFScheduler / Output to File
CF - Session Variables
In a multiple-server environment, it is likely that visitors will jump around to multiple servers during the same visit in order to always use the fastest one per page.
Session variables are stored in individual servers, so if visitors jump around the variables don’t jump with them.
Solution: Store an ID or “uuid” in a cookie or in a URL variable and keep the user’s variables in a database.
Database Suggestions
Use stored procedures where possible. Let SQL do the work where appropriate. Learn your Query Optimizer Use Indices Appropriately (INDEX=…) Have Enough RAM to Store Your
Databases, Indices and Have Extra Identity Columns & @@identity Ordering Your WHERE Clause
Database Suggestions - Cont.
Max(), Min(), Sum() and Count() - Use! Review SQL Execution Plans!
Identify Bottlenecks and Fix in Development
Use Verity, Not SQL, For Word Searches Use (NOLOCK) If “Dirty Reads” Are OK.
Web Log Analysis Download Your Web Logs and Run them Off-Line
- Save Your Web Server CPU. If You Won’t Use It - Don’t Report It Remove .GIF/.JPEG From Your Analysis
They Don’t Count They Slow Down the Reporting
Don’t Do Reverse IP Lookups It Slows Down Reporting a LOT Let’s Face It - AOL IS 30-50% of the Users The Military Will Hate You
How To Monitor Your Systems
IpSwitch - WhatsUpGold IpSwitch - iMail for NT (w/ Monitors) Keynote - World-Wide Sensor Network Spectrum - $$$ ClusterCats Administrator (CF Enterprise)