Steve asks:
I would like to get an email every time that a page runs long enough to get logged as a long-running page. Any suggestions?So - just in case you didn't realize, there is an option in the ColdFusion Administrator that allows you to timeout requests that take too long. If you turn this option on, and a page takes too long to run, an error will be thrown.
I thought this would be a simple thing to do then - simply modify my onError inside my Application.cfc to notice these errors. However, I noticed something odd. For some reason, my onError code didn't correctly handle the exception. This may be a bug. When I switched to <cferror type="exception" template="exception.cfm"> it worked as expected.
How can we use the exception template? Here is a simple example:
This is exception.cfm.
<cfif findNoCase("The request has exceeded the allowable time limit", error.message)>
send email here
</cfif>
I used a findNoCase since I didn't see a nice exception type. How would you know what template? The error.template value shows the file name. You can also find out the tag that causes the problem. The last portion of error.message contains it:
The request has exceeded the allowable time limit Tag: cfoutput
You can also determine the line number by looking at error.rootCause.diagnostics - however - a warning on that. In my initial testing, I used the cferror tag and the onError template. When I did that, the error structure only mentioned a line within my onError method. I had to comment out onError and only use cferror in order to get the real line number. I'm thinking there may be an issue with onError and this particular exception type.
Archived Comments
Now that could be useful.
How many of these ask jedi questions would be useful to put on coldfusioncookbook?
Maybe so. There will definitely be some overlap at times. I kinda feel like this question is a bit -too- unique for the cookbook. As I've said before though, I'm still feeling it out.
I think ideally you could answer these questions here and get comments, suggestions, alternative solutions, etc - and then condense that info into one concise Cookbook entry.
Jim
Just a reminder, ColdFusion will generally *not* timeout requests that are waiting for a response from a database.
The exception to this rule is that Oracle and SQLServer JDBC drivers should obey a CFQUERY timeout attribute if one is provided (while still ignoring the general CF Admin timeout). Other database drivers generally will not timeout while waiting for a database to respond to a query.
In my experience, most reports of ColdFusion server hanging can be attributed to queuing that occurs when the database is slow or unresponsive.
http://www.talkingtree.com/...
Hey! That was me!
Thanks for the answer. Is it possible to get the email message and still allow the long-running process to complete?
I am hoping to let things like this work, I just want to know that they are taking too long so that I can optimize them.
In any event, thanks for taking the time to answer my question.
Steve, no, once the exception is thrown, that should be it. What you can do, however, is simply time the problem code. You can do this using getTicketCount. If the result is bigger than some value, send an email. This assumes you DONT have the option turned on i the admin to throw an error, or it is set to a higher value, and you want to check for a lower value.
Since the responses to Steve's question are based on throwing an error, I'd like to point out another way to look at the question, Steve wants a report on when a page takes too long, not necessarily terminate a process.
This gets into performance tuning and monitoring. There is an attribute for logSlowRequests in the coldfusion.server.ServiceFactory.RuntimeService, though I've never played with the logs to find out what actually gets logged if the boolean is set true. Essentially, you would need a service that tails the log and notifies via email whenever a slow request was logged.
Steve might also want to look into stress testing and monitoring products such as
Mercury LoadRunner
http://www.mercury.com/us/p...
Microsoft Stress Testing page
http://support.microsoft.co...
Segue Silk Performer
http://www.segue.com/produc...
Ray,
getTickCount! I have used that several times, but it didn't occur to me for this. This is absolutely what I was looking for.
Christopher,
Thanks for the suggestion. I will look into that ServiceFactory at some point. It certainly sounds interesting. For now, I think the getTickCount solution will suffice.
I am using Microsoft's old Web Application Stress Tool right now and it seems to meet my needs.
Thanks!
If your goal is to keep a eye on the health of ColdFusion take a look at SeeFusion. Use this in combination with a monitoring application like IPMonitor to notify you if there is a trend in long execution times. This way you have a log of what exactly were the templates that took a long time to run as well as way to monitor if your site is starting to crawl. Take a look at the Breeze presentation that the guys from Webapper did for the Phoenix ColdFusion users group.
http://mmusergroup.breezece...