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 testing system such as OpenSta to develop a performance baseline for your application. You should know exactly how much memory your application uses, how many requests a second it can handle, the level of CPU usage during normal operation, and so on.
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.
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.
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.
The Application.log file records every ColdFusion error on your site. Two types of errors in particular clearly indicate a performance problem.
The first is a "Request timed out" message. This error comes up if a ColdFusion page takes longer to process than the TIMEOUT value you set in the ColdFusion Administrator.
If your server is experiencing performance problems, some pages take so long to process that they trigger this error. If you have set your TIMEOUT value to 20 seconds, you have no way of knowing whether the pages that aren't timing out are taking 5 seconds or 15 seconds to process. If you're getting "Request timed out" errors for only a few specific ColdFusion pages, odds are those pages are at least one source of your performance problems. If these errors are spread evenly across most or all of the pages on your site, a single bottleneck may be affecting everything.
It's normal for ColdFusion to rely heavily on the processor and to grab memory as necessary to pull a large number of records from a database. Memory usage should climb, plateau, and then release. However, if you find that memory use on your Web server is increasing without ever releasing, look in the application log for database-related activity.
If you find many errors (and especially if you see entire queries in the application log with associated errors), examine your database queries and see how you can tighten them up. Other issues can create what appear to be memory leaks, from threads never releasing, to synchronization issues. One of your best resources for solving these sorts of problems is the collection of log files described here.
The Exception.log is one of the more useful ColdFusion logs and probably the first place you should look if you are seeing ColdFusion application errors. Many ColdFusion developers are uncomfortable with the exception log because it shows Java stack traces, which are very detailed and full of seemingly undecipherable Java messages.
When properly understood, however, the stack traces offer detailed information on exactly what was happening when the system experienced the problem that created the exception.
A full discussion of Java stack traces is beyond the scope of this book, but you'll find an excellent introduction to this topic at http://java.sun.com/developer/technicalArticles/Programming/Stacktrace/. Once you understand these exception messages, you can quickly determine hung threads, failed requests, memory problems, and much more. Even without a full grasp of the stack traces, you will be able to see which file threw the exception, at what time, and what part of ColdFusion experienced an issue.
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.
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 performance. Additionally, the Web server logs often provide clues to other issues, such as gaps that might allow security breaches or attacks, as well as information on how real users are experiencing the application.
For all these reasons, good log-analysis software is essential in analyzing your Web server's log files. Since Web server log analysis isn't specific to ColdFusion we will not delve deeply into it. You should know, however, that without a good log-analysis tool, you'd be severely handicapped in all your other performance-analyzing ventures. If you don't have a log-analysis tool right now, you might like to look at Analog (http://www.analog.cx/), a free tool written in Perl. If you need more-powerful analytic tools, consider WebTrends's Enterprise Suite (http://www.webtrends.com/), one of the most popular commercial Web log-analysis tools. It offers ad hoc reporting and graphical representations of logged data.
Analyzing Web server logs will tell you about visits, users dropping off in the middle of a transaction, and general user activity. You can set up your Web server to store valuable statistics about your site. These can be very beneficial for tracking information about your site and then comparing the data to your load testing data. You can find how many users are visiting, peak loads, page-load times, and most-visited site sections, among other information. This analysis can also show where visitors are leaving your site, maybe due to problems such as errors or slow page-load times. Understanding how your users interact with your site can be very beneficial in creating a high-performance Web site.