Go with your gut, but I doubt the millisecond of time that passes will
change anything... Also reads and writes to application variables
should be locked so the outer CFIF is not necessarily a good idea.

You might consider setting the var to SOMETHING before the long init
process... Here's why...

The inner cfif is a good idea anyway... that ensures that the process
only goes once.. by the end of the lock, the var should be set and
you're good to go..


On Fri, 31 Dec 2004 00:00:41 -0500, Jim Davis
<[EMAIL PROTECTED]> wrote:
> I've been having trouble with my application starting up under load.
> Couldn't figure it out.  Once it got going the application purred like a
> contented cat, but the start up was another matter.
> 
> Under even moderate load the app would kill JRun.  Not good.
> 
> Finally figured it - and I'm a dumb ass.  I have code like this in the
> system to handle start up tasks (which might take as long as 10 seconds to
> complete):
> 
> <cfif NOT IsDefined("Application.Init")>
> <cflock name="InitApplication" timeout="30" throwontimeout="yes">
> 
>        ... long init process ...
> 
>        <cfset Application.Init = true />
> 
> </cflock>
> </cfif>
> 
> See the problem?  I didn't.  Of course (like most things this works in
> development fine - but under load the first thread will begin the process
> and ALL the other active threads will queue up waiting to START IT AGAIN!
> 
> Damn I'm dumb.
> 
> The following code stops this from happening.  Check the marker, then wait
> for the lock - but then CHECK THE MARKER again to make sure you have to do
> it!
> 
> <cfif NOT IsDefined("Application.Init")>
> <cflock name="InitApplication" timeout="30" throwontimeout="yes">
> <cfif NOT IsDefined("Application.Init")>
> 
>        ... long init process ...
> 
>        <cfset Application.Init = true />
> 
> </cfif>
> </cflock>
> </cfif>
> 
> Completely eliminated all my start up issues.
> 
> I suppose I could just get rid of the outer CFIF but then I'd be setting the
> lock on every page - I've a gut feeling that's heavier than just doing the
> CFIF.
> 
> Jim Davis
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - New Atlanta
http://www.newatlanta.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189044
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to