ColdFusion Timeout

I was recently consulting with a client who was experiencing timeout issues due to long running requests. This issue has plagued their site for quite awhile. My approach to solving their long running requests was to jump into the CF logs to find out what might be the problem.

The challenge was that it was a legacy fusebox site and because of the architecture of this version of fusebox every error pointed to index.cfm. The logs were somewhat helpful with regard to the timeouts and where exactly the error was coming from at a higher level of the multiple application supporting server. Noticing that it was a particular application, I challenged the development team to wrap all cfquery/cfstoredproc requests in a cftry/cfcatch. As is the case with many CF developers (including myself when I was starting out) it is easy to take for granted that the database is always going to be stable and ColdFusion's very straightforward ability to query the database will execute with no problem.

This is a huge mistakes in application development no matter what technology you are working with. In code for the immediate application i.e. CF, java, C#, VB, etc. anytime the application has to go outside of itself to query a database, web service, shared api call, etc. this code must be contained in a try or catch because it can fail due to multiple reasons.

Back to the CF issue... I recommended that the client update the queries (no timeout for cfstoredproc, wonder why?) with a timeout settings forcing it to fail (this would identify the long running query) and due to CF throwing a time out error the cfcatch could write a very detailed description from the given cfcatch scope and then they could write the actual page and line of code where the failure happened. At this point after this code was implemented they could then place a cfthrow tag at the end of the catch to bubble up the error to a global error handler in Application.cfc so that it would be handled gracefully by displaying a friendly error page.

Sorry if I'm getting wordy... Thoughts tend to flow when blogging and sentences run-on... So you may be thinking, I have a huge application with queries all over the place where the heck do I start? If you are a dreamweaverer or cfeclipser or homesiter you have the tools at your disposal to do a sitewide search. I like dreamweaver's and homesite's search capabilities due to the fact that you can export the file list in various formats and organize a plan of attack with your team to patch up the application. You'll have your site ready to diagnose itself and in turn be able to stabilize or reengineer the failed module.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
You may want to try using tools like FusionReactor, SeeFusion or even cfWatcher to better identify the location of the problem and the problem itself.
# Posted By Ed | 2/22/07 3:07 AM
Alternatively check the web server log files, as these will include the query string for each page request which will help you to identify the Fusebox fuseaction being executed.
# Posted By Andy Neale | 2/22/07 4:47 AM

sometime database response so slow that seems CF doing something, MS-SQL server have problem if database log file grow over 20 GB. Database log is also important to identify what could be the reason. I tried fusionreactor to find why response is slow but to be honest did not get much out of it.
1: There is option in database settings to set timeout for queries.
2: CF admin database connection setting have option for timeout.


# Posted By sana | 2/22/07 5:38 AM
Ed, I am a big fan of SeeFusion (this blog entry was something I did over the phone). I have considered training this client on SeeFusion and its benefits. Thank you.

Andy, good point, I will have them line up the times in CF and web server logs.

Sana, thanks, I had them set up cfquery timeout which I described in my blog entry. It is also important to note that the page request timeout setting in the ColdFusion administrator must be greater than the specified timeout in the cfquery.

Thanks for your responses.
# Posted By Strikefish | 2/22/07 7:47 AM
As for me CF works without any troubles.
Good luck everyone!
# Posted By Andy | 8/2/07 3:39 PM
I can't get the TIMEOUT parameter of CFQUERY to work for the life of me. I'm using CFMX 7.0.2 with MS SQL Server 2005. This is what I run:

<cfquery name="test" datasource="dsn" timeout="1">
select top 20000 *
from table </cfquery>


That query outputs a number that's in the 3000s -- which should never happen, right? Since the timeout is set for 1 second (or 1000ms). Why is this happening? I thought the TIMEOUT paramter works with SQL...
# Posted By Sung | 4/14/09 4:23 PM

cfquery scope is cumulative. Are you running multiple queries possibly in onRequest, on the the cfc, or cfm? What you want to do to be most accurate for the cfquery block is use getTickCount.

I'm betting that query is sub second.

Example and info here:
# Posted By Strikefish | 4/16/09 3:10 PM
@Jeff Bouley,

Check out the further tests I've run here:

At this point, I'm convinced the TIMEOUT param in CFQUERY doesn't really work properly. In my example, it's a very simple single query, that's all. No onRequest on cfc (not using CFCs in this example); nothing cumulative. I hope somebody can prove me wrong.


- Sung
# Posted By Sung | 4/16/09 9:05 PM

Copyright Strikefish, Inc., 2005. All rights reserved.