Transcript Slide 1
ColdFusion
Performance
Troubleshooting and
Tuning
Grant Straker
Technical Director
Straker Interactive
CFUNITED – The premier ColdFusion conference
www.cfunited.com
What I’ll Cover
Why we need to performance tune
Understanding the architecture
Principles of Troubleshooting / Tuning
How to setup a Test Rig
Troubleshooting / Tuning process
Caching Strategies
Memory Leaks
June 28th – July 1st 2006
Technology Gap
Acceptable Deployment Time
Technology
Gap
Time
Application Load / Complexity
1950
June 28th – July 1st 2006
1980
Year
2000
CFMX Architecture
June 28th – July 1st 2006
Principle One
3 Sources of performance problems
CPU Bottleneck (Threads)
Memory Management
Network / Disk (IO) problems
June 28th – July 1st 2006
Principle Two
To find the issue you will have to:
Simulate the load under which the
system is failing
Record the relevant diagnostics when
the system is failing
Interpret the results and adjust the
application code and/or server
configuration accordingly
June 28th – July 1st 2006
Principle Three
There are 5 things you can adjust (tune)
to try and resolve any issues:
1. Application Code
2. ColdFusion Administration Settings
3. Application Server Settings (JRun /
JVM)
4. Web Server Settings
5. OS & Network Settings
June 28th – July 1st 2006
Troubleshooting Prerequisites
Getting up-to-date
ColdFusion
http://www.macromedia.com/cfusion/know
ledgebase/index.cfm?id=tn_17883
Jrun
http://www.macromedia.com/support/jrun/
updaters.html
June 28th – July 1st 2006
Metric Logs
/CFusionMX/runtime/servers/default/SERVER
-INF/jrun.xml
/jrun4/servers/[instance name]/SERVERINF/jrun.xml
busy - Threads that are running (executing
code) this number will not exceed jrpp active
threads for JRun or simultaneous request set
in the cfadmin
total - Total number or jrpp and web threads
that are currently available.
June 28th – July 1st 2006
Create a trace log
All requests not just current request
(cfdebugging)
Can be added to give more granular
details
Easily turn on/off
Low overhead
SeeFusion
June 28th – July 1st 2006
Load Testing
Accurately Simulate Real Load
Benchmarks
Input
Users / Requests
Output
Throughput
CPU
JVM
Threads
June 28th – July 1st 2006
Options
Paessler Web Stress
Microsft Web App Stress Tool
Mercury LoadRunner
Segue Silk Performer
Appperfect
June 28th – July 1st 2006
Test Rig - Debug Console
Garbage Collection
JRun Metrics
Server Stats
CF Error Log
Trace Log
June 28th – July 1st 2006
Thread Dumps
Tell us low level information about current
running processes / Threads in the JVM
Give us diagnostics
Will pinpoint performance bottlenecks 99% of
the time
Are easy to take but require a bit of
understanding
Take 3, 15 seconds apart – check for
common threads across all 3 dumps
June 28th – July 1st 2006
Troubleshooting Process
1.
2.
3.
4.
5.
Simulate Load
Review Debug Output
Take Thread Dumps
Adjust Code
Repeat until resolved
June 28th – July 1st 2006
Tuning JRun
Jrun.xml
Scheduler Service
internal Jrun service that handles the queuing of
threads to the processor
Proxy Service
internal Jrun service that handles the connection
between native web servers (IIS, Apache) and Jrun
activeHandlerThreads is the most important attribute
June 28th – July 1st 2006
Tuning JRun Continued…
Active Handler Threads – 25 default for both
SCHEDULER and PROXY services.
Recommend 25 Per processor (4 x processor
= 100)
Set too low = bottlenecks, thread deadlocks
Set too high = excessive context switching
Needs to be tuned
June 28th – July 1st 2006
Tuning JVM
-Xmx most important – 1GB max on
windows
-Xmx too big = long GC cycles
-Xmx too small = OOM Errors
Permsize also important
GC monitoring
Various switches to assist
June 28th – July 1st 2006
Tuning JVM continued…
Different Types of Collectors
Low Pause Parallel
-XX:+UseConcMarkSweepGC XX:+UseParNewGC
Parallel Scavenge
-XX:+UseParallelGC XX:+UseAdaptiveSizePolicy XX:+AgreesiveHeap
June 28th – July 1st 2006
Alternate JVM’s
JRockit (BEA)
IBM
Not all JVM’s are the same and need to
be thoroughly tested before switching.
June 28th – July 1st 2006
Java 1.5
Not a currently supported version of
CFMX
Will run on CF7.1 and JRun updater 6
Much better performance
Excellent debugging
June 28th – July 1st 2006
Memory Leaks
Prevention is easier than diagnostics
Requires Java profiling tool to
accurately identify
Easier to find in Java 1.5 JVM’s
If memory increases after forcing GC
June 28th – July 1st 2006
Caching Strategies
Store instantiated objects in application
scope – careful as incorrectly scoped
variables may cause memory leaks
Memory Caching
Limited by size of Heap
Requires and architecture for clearing
cached item
June 28th – July 1st 2006
Database Performance
JDBC Trace Tools
SeeFusion
Maxrows
Only use “Select *” if you really have no
option
Use cfqueryparam to increase query
performance
Use blockFactor to increase query
performance
June 28th – July 1st 2006
Coding for performance
1. Don’t Run a query larger than the size of the
heap
2. Ensure all your variables and functions stored in
persistent scope are var’ed.
3. Code to allow for slow or missing connections to
the database or file system
4. Don’t run process intensive external calls on
every request
5. Ensure you use all the caching options available
6. Tune your server for your application
June 28th – July 1st 2006