Monitoring Your ColdFusion MX 7 Server
Monitoring system performance involves two major approaches: historical analysis and active system monitoring.You can incorporate many methods into your monitoring activities. Usually you need to implement a combination of monitoring activities into your infrastructure to comprehensively monitor the site. Let's first discuss analysis of past system performance, or historical analysis. Next we will look at active system monitoring of ColdFusion Web serverswhich may involve setting up server probes, utilizing performance monitors and third-party utilities, and other techniques.
Developing a Baseline
One of the first things you want to do before you start monitoring a application is have or create a 'baseline' for you system. A baseline is a set of metrics that define how your system and application should behave under normal conditions. Usually you do this by using a load and application testingChapter 1 describes various testing tools for gathering this information.Once you have created your system baseline, you'll have a set of metrics against which to compare your system's operation, which will help you in locating problems. Every time you make a significant changes to the system, apply patches, upgrade ColdFusion, or apply new code, run your tests again and compare the system performance with your original baseline data. Do this as soon as you make the changes on your test environment, so you can see before deployment whether the alterations will have a negative impact on the application's overall performance, stability, and viability.
Historical Analysis
One of the most important methods for understanding your application, successfully troubleshooting it, and improving it, is historical analysis. Historical analysis is simply comparing data collected from your system over time to see what patterns, trends, or changes emerge. You can use historical analysis to detect security threats, bugs, problems with performance, bottlenecks, and much more.ColdFusion offers several features for analyzing historical performance on your application server. By combining this data with other information stored on the server, you can create a clear picture of how your application is performing.
Analyzing ColdFusion Log Files
A consistently small system log file correlates to a healthy Web site. Regular monitoring of the ColdFusion log files is a key component to maintaining and improving your ColdFusion applications. Concentrating on reducing the number of errors that appear in the log will eventually produce a healthier, more responsive site. ColdFusion log files consist of several files representative of functions within the ColdFusion server, shown in Table 2.1.Though not as useful at first glance as the exception log, the Server.log also provides information related to the stability of your Web servers that might further substantiate your application log findings. Search this log for "ColdFusion started," which indicates how often your Web server has been started and stopped.
Other Logs
ColdFusion MX 7 provides two places for tracking long-running requests. In Debugging Settings, you can set a benchmark (in milliseconds) and display any requests that take longer than the setting in the debug output. Additionally, you can log all pages that run longer than a given number of seconds to your Server.log. See Figure 2.1 for setting logging of long-running pages.
Figure 2.1. Log pages that are running too long.
[View full size image]

JRun Metrics
If you are using the standard version of ColdFusion, or ColdFusion for J2EE deployed on JRun, you can take advantage of yet another set of log files, as well as the enhanced logging capability in JRun. Look in the ColdFusion MX 7 install directory and go to \runtime\logs. You will see the logs listed in Table 2.2.
LOG NAME | FUNCTION |
---|---|
coldfusion-err.log | ColdFusion stack traces. |
coldfusion-event.log | ColdFusion event log. |
coldfusion-out.log | ColdFusion services events, and data from garbage collection. |
METRIC | DESCRIPTION |
---|---|
listenTh | Threads listening for a new connection. |
idleTh | Threads waiting for a new request. |
delayTh | Threads waiting to run. |
busyTh | Threads currently running. |
totalTh | Total worker thread count. |
delayRq | Requests delayed due to high concurrency. |
droppedRq | Requests dropped. |
handledRq | Requests handled. |
handledMs | Milliseconds spent servicing requests not including any delay time (delayMs). |
delayMs | Milliseconds spent in delay state. |
bytesIn | Bytes read from requests. |
bytesOut | Bytes written to responses. |
freeMemory | Kilobytes of free memory in the heap. |
totalMemory | Total kilobytes in the heap (in use and free). |
sessions | Current number of active J2EE sessions. |
sessionsInMem | Number of J2EE sessions in memory. |
After you have found this file you should make a back up since we are going to change this file and if you make any mistakes ColdFusion server may not restart. Usually it is easy enough just make a copy of jrun.xml and call it jrun_original.xml or whatever is easy for you to remember. Now that you have made a back up copy open the jrun.xml , open it with any text editor. Look for this entry and uncomment it:
C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\jrun.xml
Then find this entry:
<service name="MetricsService">
<attribute name="bindToJNDI">true</attribute>
</service>
and edit its attributes. You want to change metricsEnabled to True, and meTRicsLogFrequncy (the interval, in seconds, to log metrics) to somewhere between 5 and 10 seconds. So you should have something that looks like this:
<service name="LoggerService">
The information that will be recorded to the logs will look something like this:
<attribute name="metricsEnabled">true</attribute>
<attribute name="metricsLogFrequency">5</attribute>
Next, split the logged information into its own log file. Do this by editing this line:
10/14 12:11:23 metrics Web threads (busy/total): 0/2 Sessions: 2 Total Memory=7052 Free=3303
to this:
<attribute name="filename">{jrun.rootdir}/logs/{jrun.server.name}-event.log</attribute>
[View full width]<attribute name="filename">{jrun.rootdir}/logs/{jrun.server.name}- {log.level}. log<Once you have changed the jrun.xml file you will need to save the file and restart ColdFusion for these settings to take effect. Once you restart ColdFusion you will see that all the metrics data you record while troubleshooting will go to a separate log, coldfusion-metrics.log.NOTEDon't forget that turning on JRun metrics has a performance impact on your server and rapidly creates very large log files. Make sure that once you have resolved your issues or captured all the information you need, turn off the JRun metrics./attribute>
Analyzing Web Server Log Files
Sherlock Holmes often said "Eliminate all other factors, and the one which remains must be the truth." Trying to debug and troubleshoot your application can sometimes seem an impossible task when the problem is not apparent or obvious. In these cases you need to look methodically at everything that may be affecting your system. One of the major components in a ColdFusion application is the Web server, and careful monitoring and analysis of its logs are crucial to maintaining system