Copy link to clipboard
Copied
I am new to CF.
Let's say a company maintains a website which is "run on one instance of Cold Fusion."
Let's say I am visiting a webpage on this website which has poor code on it. The page consumes a lot of server resources. Maybe there's a recursive loop or just a lot of calculations being done.
If I visit this poorly coded page, will the server NOT serve up any other pages to any other users until my request is done (which it won't be for a while)?
I am new to the forum, so please let me know if this question would be better placed somewhere else.
Copy link to clipboard
Copied
CF is multi-threaded so - no - everyone else will not need to wait until your bad reques finishes before the next request is processed. However if the thread is thrashing the CPU, the entire box will slow down, yes. I don't think there's anyway of proofing aganist this (on Windows, anyhow... I can't vouch for *nix).
On production boxes there's usually a request time out set, which will cause any request which take longer than a few seconds will be killed, so it's seldom a problem on a well-configured server anyhow.
Requests running away with JVM memory is usually more of a concern.
--
Adam
Copy link to clipboard
Copied
Regarding
However if the thread is thrashing the CPU, the entire box will slow down, yes.
We have found that the entire box slows down to the extent that nobody can browse anything and we end up re-starting CF. The most frequent causes are related to database problems.
Copy link to clipboard
Copied
There's nothing wrong with asking this question here, don't worry about that.
As Adam says, your server will be able to serve other requests concurrently. But ...
The server creates a thread pool at startup with a preset number of threads, which you can configure in the CF Administrator. The server can run that number of concurrent requests. If it has more requests than threads to run them, the excess requests will be queued, then handled by threads that finish their current task. The server will not create additional threads beyond the preset number.
So, if you have one long-running request, the thread serving that request won't be able to do anything until the request completes or is timed out. This will cause other requests to spend more time in the queue, even if there aren't any other resource contention issues. And what if another request for the same script is executed? Then, assuming that's also a long-running request, there will be fewer threads to handle the queue, etc.
By default, requests will time out after a preset period, and you generally want to keep this preset pretty low to minimize the issue described above.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/
Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.
Read this before you post:
http://forums.adobe.com/thread/607238
Copy link to clipboard
Copied
As Adam briefly mentioned, a bigger concern is resources -- what is this recursive loop doing and could it be eating all your memory, your DB connection pool, or something else? All these other resources can bring a server to it's knees, ot kill it altogether. Here are two examples:
--- Example 1 ---
<cfset variables.iteration=0 />
<cfloop condition="variables.iteration LT 100">
<cfset variables.iteration=1 /> <!-- programmer meant to code variables.iteration=variables.iteration+1 -->
</cfloop>
--- Example 2 ---
<!-- I perform a query and based on the result, i may recursively call myself -->
<cffunction name="cleverRecursiveFunc" output="false" returntype="void">
<cfargument name="iteration" type="numeric" required="yes" />
<cfset var qry=0 />
<cfquery name="qry" datasource="myDS">
select * from [invoices]
where
department = <cfqueryparam value="#arguments.iteration#" cfsqltype="CF_SQL_INTEGER" />
</cfquery>
<cfif qry.RecordCount GT 0>
<cfset arguments.iteration=1 /> <!-- programmer meant to code arguments.iteration=arguments.iteration+1 -->
<cfset cleverRecursiveFunc(arguments.iteration) />
</cfif>
</cffunction>
Example 1 will simply burn a thread until the page timer expires (assuming there is one), slowing down the CPU slightly in the process. For the most part, it is benign, unless you run out of threads.
Example 2 on the other hand burns up resources and can bring a server down. And depending on how fast the resources are being burned, can easily bring down a server before any page timeout kicks in.