Title: Power for Web Applications.
1Power for Web Applications.
- Scaling Cold Fusion Applications
- Douglas Nottage, Autobytel.com
2What 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.
3Examples 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 youre not online, Ill buy my toys elsewhere.
4This 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 Doesnt Live on One Application
Alone - Putting it All Together . . .
5The Big Bang - Getting Started
- Management wants a web site . . . Today!
- Finance wants you to use one of the faster
computers on someones 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!
6The Big Bang - Getting Started
- 8 am - Marketing runs commercial.
- 5,000 people visit in 30 minutes.
- IIS reports 300 currentconnections.
- Your boss cant get pages toload 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?
7Puberty - Growing Quickly
- We need a faster server!
- More RAM!
- Access is for kids . . . Lets upgrade to SQL
Server! - Download the web logs and run WebTrends on your
desktop.
8Commercial 2 - Hell on Earth!
- 8 am - Commercial Airs
- 805 am - Server hits 300 connections.
- 810 am - Extra RAM Is Unused. Why?
- 815 am - Pages are running really slow.
- 816 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?
9Round 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.
2
1
3
4
Faster PC or Server
Desktop PC
10Round 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?
2
1
3
4
Faster PC or Server
Desktop PC
11Round 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
(21 Ratio).
2
1
3
4
Faster PC or Server
Desktop PC
12Round 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?
2
1
3
4
Faster PC or Server
Desktop PC
13Hardware Solution
- Hardware load balancers like Ciscos 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.
3
2
4
1
Have a second device around in case the first
fails.
14Software 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.
2
3
4
1
Server 1 is too busy. User is redirected to
Server 2
Server 1 tells Server 2 it is nearing capacity
and starts sending users there.
15Hybrid 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 servers
health than the hardware does.
3
2
4
1
Have a second device around in case the first
fails.
Servers tell the hardware load balancer how they
are performing.
16After 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.
3
2
4
1
17NT/SQL Clustering
Web Cluster
- 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.
SQL Cluster
Drive Array
18Bandwidth Limits and Costs . . .
- Customers now rely upon Company Xs 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?
Consumers
Big Demand
Limited Bandwidth
Web Cluster
19Using Cheaper Bandwidth . . .
- Company X changes all tags to point
toimages.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.
Consumers
Limited Bandwidth is used for Cold
Fusion (Dynamic Content) Pages Only
ISPs Web Server w/ GIFs / JPEGs (Cheaper and
larger capacity for static content)
Web Cluster
20Deploying Code to Many Servers
Web Cluster
- 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 its live for all.
Data for CF
CFML Pages for IIS
SQL 1
SQL 2
Drive Array
21Creating 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 cant 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?
22Proposed System Architecture
Development
Off-Site
Image / Proxy Servers
Extranet Users
Developers
Fiber Channel Drive Array
Extranet
Production
eCommerce Site
SQL Application NT Cluster
End Users
Test Team
Testing
23What 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 . . .
24Summing 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
25Cold 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!!!
26Cold 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 dont use them. - Deny CF Studio Access in production.
- Rotate CF Admin passwords regularly
- Dont Do Beta Wait Until It Is Released
27Cold 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.
28Cold Fusion - Scalability Issues
- White Space Kills! - Strip it!
-
- 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
29Cold Fusion - Scalability Issues
- Application.cfm is NOT a Cure All
- Loads on EVERY Page
- Youre 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
30CF - 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
dont jump with them. - Solution Store an ID or uuid in a cookie or in
a URL variable and keep the users variables in a
database.
31Database 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 _at__at_identity
- Ordering Your WHERE Clause
32Database 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.
33Web Log Analysis
- Download Your Web Logs and Run them Off-Line -
Save Your Web Server CPU. - If You Wont Use It - Dont Report It
- Remove .GIF/.JPEG From Your Analysis
- They Dont Count
- They Slow Down the Reporting
- Dont Do Reverse IP Lookups
- It Slows Down Reporting a LOT
- Lets Face It - AOL IS 30-50 of the Users
- The Military Will Hate You
34Web Log Analysis
- Frames More Pages to Analyze Bad
- Dont Use SQL-Enabled Web Analyzers
35How To Monitor Your Systems
- IpSwitch - WhatsUpGold
- IpSwitch - iMail for NT (w/ Monitors)
- Keynote - World-Wide Sensor Network
- Spectrum -
- ClusterCats Administrator (CF Enterprise)
36Remember . . .
- Scalable Applications Scale with Cold Fusion in
Scalable Environments. - Does your Application Scale?
- Thanks for your time and Good Luck!