2
votes

I have a ColdFusion template that executes a long running query. I have increased the request timeout from 3600 to 6600 but my template continues to timeout. I would like to increase the request timeout again from 6600 to 9600 but before doing so I would like to know if there are any disadvantages or risks from increasing the request timeout so much?

Basically, what my cfm file does is. It has to take records from a table and insert them into an excel sheet. The table consists of around 30,000 records. The cfm file takes every 1000 records at a time and inserts them into Excel, then it takes the next 1000 and so on. To complete this entire process it sometimes stops abruptly because of the timeout problem. So before I increase the "requesttimeout" I want to know, would there be any problem (ram usage, performance) if I increase requesttimeout tremendously.

3

3 Answers

5
votes

Upping the timeout is fine where it's needed. You should use cfsetting requestTimeOut="xxx" to up the timeout just where it's needed, not upping it in the administrator, as that will affect all templates.

The disadvantages are that there's a pool of threads to handle requests and whilst one is handling your long-running request, it's not available to do other things. This is fine as long as you're confident that the long-running request will only be run by one or two people at a time, but problematic if lots of people could be running it. If CF will run 8 requests concurrently and all 8 are hadnling your long-running request, then your site is effectively offline. CF will queue requests up to a certain point, but you don't want to get to this state in the first place.

I've worked on apps where there are background admin-only tasks which can take up to an hour, but we were confident that no more that 2 people would ever run them.

You could also look at using cfthread in order to run your query without blocking the page, but then it's harder to provide feedback to the user.

1
votes

I think it would help if we understood the situation a little better. Is this something like a nightly job that is run? Or is this a page that a user might navigate to which generates a report while they wait for it? Give us some basic information about what your page is doing.

Also, there are different ways to increase the request timeout; system wide via the administrator or page specific via the <cfsetting requestTimeOut=""> tag. Which one are you increasing? I would suggest that you not increase the system wide setting but it is okay to increase the page level setting when needed.

There is also a timeout attribute for the <cfquery> tag. Are you using that?

Can you tell us if the <cfquery> is timing out or if the timeout is happening after the cfquery and during the data output?

I would also suggest attempting to optimize your query as much as possible. Can an index be setup (if one is not already)? Do you really only need a subset of the records being returned?

Perhaps you could split this one page up into multiple pages that would each run faster.

0
votes

Rather than just increase your timeout limit, IF the user who initiates the request doesn't need to wait for the results (i.e an end of day or overnight report) then I would use a cfthread with its timeout set to 0 (never times-out) and leave it running in the background until it has finished, or set an extremly long timeout, like 1 hour. I would also use cflock to prevent the thread being able to proccess more than once otherwise you could grind your system to a halt with many heavy threads.

read this -docs- and see what you think