Title: Strategies For Scaling ColdFusion
1Strategies for Scaling ColdFusion Caching
2Page Request Supply Chain
3Typical Work Breakdown
Avg. Page Response time 7 seconds
SQL Queries
CF Logic
Web Server
Internet
IE NS
5 x 30 ms 150 ms
5 x 100 ms 500 ms
5000 ms
1000 ms
50 ms
Transport
Data Access
Client Rendering
Business Logic
Presentation
4Generating Pages Faster
1. Smaller pages smaller images less whitespace
2. Faster transport over network
3. Faster CF page generation
4. Faster DB access
SQL Queries
CF Logic
Web Server
Internet
IE NS
5What is Caching?
- Temporary storage of the data from a prior
process as possible to the next data consumer - Cached data can be accessed programmatically
served by network appliances/processes - Optimized data format
6Opportunities for Caching
Business Logic
Client
Transport
Data
Middleware
Application Servers
Internet
Web Server
File System
COM
Network
RDBMS
Cold Fusion Application Server
EJB
Web Browser
Web Server
JDBC
Routers
OTHER local
MQ
OTHER remote
Request Processing
7Caching Techniques
Web Browser
Cold Fusion Application Server
RDBMS
Routers
Web Server
Java
Network
Webserver Caching xCache caches fully or
partially rendered CF pages and strips
whitespaces
DB Caching Most database systems have have
facilitates to cache frequently requested
data. Additionally, 3rd party tools like
timesten offer remote DB caching
CF Caching Stores optimized, rendered and/or
processed data.
Client cache Caches entire page on browser
Cache appliance Caches text or images
Object Caching PowerTier maintains
a transactional, distributed cache of java
memory objects. Can be configured to write back
to RDBMS or other data providers.
Cache network Akamai, Sandpiper
8Caching Checklist
- DB caching
- CF caching
- Frequently used queries
- Frequently used data structures
- Rendered HTML (components, partial pages)
- Entire pages (CFCACHE)
- Web server caching
- xCache
- Cache appliances
- Reverse proxy server
- Cache network
9Database Caching
- Most major databases allow for caching of data in
RAM on the database server - This will minimize the work the database server
needs to do to process each request - 3rd party tools such as TimesTen
(www.timesTen.com) allows for full RDBMS
functions to be provided in a RAM based database
10 CF Cached Queries
- ColdFusion allows for commonly used queries to be
cached in RAM - This is done through the use of the CACHEDWITHIN
and CACHEDAFTER parameters of the CFQUERY tag - Using cached queries reduces the number of
network calls, as well as reducing the load on
the database
11Caching Data in CF Structures
- Using CF structures, it is possible to load large
sections of data into persistent memory variables
(server, application, session or request),
reducing the need for network connections and
database processing of each query
12Caching Data in CF Structures - Advantages
- Extremely fast queries. Serving data directly
from RAM removes costly network connections and
database processing time - Removes points of failure from the application.
Application can continue to run, even if the
database server fails
13Caching Data in CF Structures - Disadvantages
- Requires significant amounts of RAM
- Difficulties are introduced when data is updated
and must be kept consist across all machines in
a cluster - Requires more knowledgeable developers to query a
database stored in structures than it does to use
a CFQUERY tag - Requires lengthy scripts to run as a server comes
online to populate structures in RAM
14Page Caching Using CFCACHE
- CFCACHE allows page rendering speed to be
increased considerably - For pages that do not require dynamic content to
be retrieved for each user, CFCACHE will create
temporary files that contain the static HTML
returned from a particular run of the ColdFusion
page - Can be used to specify server or client side
caching, as well as cache timeouts - Can only respond to URL variables
15CFCACHE
- Advantages
- Cache can be programmatically purged
- Easy to use
- Excellent for caching page data polled using
CFHTTP
- Disadvantages
- ColdFusion still involved in processing requested
file - URL driven, can not customize based on form (or
other) variables
16Caching Semi Static Pages
- Semi static pages are any pages which are
database driven, yet identical for all users who
view it. This can include - Product information
- Company information
- Job listings
17Caching Semi Static Pages
- Static pages can be created from production data,
either using home built CFFILE solution, or 3rd
party applications such as Post Point xBuilder
(www.xcache.Com) - Verity collections can be used to search the
static HTML pagse, negating the need for a SQL
search - Index pages can be created, which link to the
static HTML
18Caching Semi Static Pages
- Advantages
- ColdFusion is not used in the process of
displaying the page - No database interaction to display the page
- Disadvantages
- Can only work for pages which are identical to
all users - Requires more space on hard drive
19Web Server Caching xCache
- xCache allows for full and partial page caching
- xCache works along side ColdFusion, and parses
incoming requests before it does - Parts of pages which should not be cached can be
marked with ltxcacheoutputgt tags, which tells
xCache to let CF parse that section of a page - Pages which should not be cached can be marked
with ltmeta namepragma no-cachegt tags - xCache administrator can be used to set caching
for sites, directories or pages
20xCache Advantages
- No coding changes necessary
- Easy to administer
- Dynamic ColdFusion at static HTML speeds
- Partial page caching possible.
- Compression eliminates whitespace
- No additional hardware necessary
21xCache Disadvantages
- Only works with Microsoft Internet Information
server - Entirely URL driven, making personalization more
difficult - Current release is language / browser ignorant
(multi-lingual sites more difficult)
22Sample xCache Metrics
23Reverse Proxy Servers
- Reverse proxy servers are hardware based caching
appliances - Sit between Web server and clients.
- Can be set to cache static files (.Html, .jpg,
.Gif, .Js, etc.) - Popular commercial products include Intel
NetStructure 1500 Cache Appliance and F5 edge
FX cache
24Reverse Proxy Server - Advantages
- Non dynamic content can be served as static HTML
files, removing the need for ColdFusion to touch
the file - Uses a separate Web server offloading the work
needed by the Web server ColdFusion uses - One cache server can cache files for entire
cluster
25Reverse Proxy Servers - Disadvantages
- Hardware based caching servers are more expensive
than software based solutions - Can not cache partial pages
- No programmatic control of cache
26Sample Intel NetStructure 1500 Cache Appliance
Metrics
27Adding A Reverse Proxy Server
28Caching Networks
- A recent trend in application architecture has
been to distribute application caches - Allows for users to download pages and graphics
from the server geographically closest - Reduces internet latency
- Removes points of failure
29Caching Networks Suppliers
- Akamai (www.akamai.com) offers distributed
caching services - F5 (www.f5.com) sells 3-DNS and EDGE-FX
controllers, allowing users to build their own
caching network - Cisco (www.cisco.com) sells DistributedDirector,
which allows customers to optimize server load by
distributing the load across disparate networks
30Conclusion
- Caching can help performance of all of the
slowest aspects of any application - Planning caching early can help save time and
money in scaling applications - Effective caching helps existing hardware handle
more requests, helping to save the costs of
additional servers - With effective caching, any application can be
scaled to handle extreme traffic