Re: Another Locking Question
On Monday, Jan 13, 2003, at 22:27 US/Pacific, Matt Robertson wrote: > Client vars are, for my money, the Holy Grail with respect to > completely > replacing session vars. Scaleable to clusters, zero locking issues, > maintain state, and expiration can be controlled precisely like session > vars with about 2 lines of code in application.cfm. Store 'em in a db, > tho'. Leave the Registry alone at all costs. Note that with CFMX for J2EE you can use J2EE session variables and take advantage of clustering, session fail over etc without the overhead of hitting the database and without the limits of cookies (to say nothing of the problems of trying to use the registry). Sean A Corfield -- Director, Architecture Web Technology Group -- Macromedia, Inc. tel: (415) 252-2287 -- cell: (415) 717-8473 aim/iChat: seancorfield -- http://www.macromedia.com An Architect's View -- http://www.macromedia.com/go/arch_blog ColdFusion MX and JRun 4 now available for Mac OS X! http://www.macromedia.com/go/cfmxosx ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Another Locking Question
Dave Watts wrote >In general, I'm not a big fan of this approach, Me neither, especially since not locking the session var in the isdefined() as was shown in the original post is improper. You would have to lock the whole thing, cfif isdefined and all. Client vars are, for my money, the Holy Grail with respect to completely replacing session vars. Scaleable to clusters, zero locking issues, maintain state, and expiration can be controlled precisely like session vars with about 2 lines of code in application.cfm. Store 'em in a db, tho'. Leave the Registry alone at all costs. My .02, Matt Robertson [EMAIL PROTECTED] MSB Designs, Inc. http://mysecretbase.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Another Locking Question
> I got a tip previously on cf-talk that advised me to do > this in my application.cfm: > > > > > > > > > > > > > > Is this good or bad? (My sites typically have between 10 > and 200 connections.) In general, I'm not a big fan of this approach, which is basically intended to keep you from having to do the actual work of using CFLOCK tags within your code. In my experience, this causes significant overhead within the application. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
YET Another Locking Question
I heard someone mention temp variables, and I had some questions about best practices in using them. Anyone mind giving some peer review? I am serious about locking all application and session scope variables. In my application.cfm, I put a read-only lock around the application scope and duplicate the whole structure into the request scope. Then I call all application variables from there, and only set application variables from within an exclusive lock. I do the same thing for the session scope. This has some obvious issues: 1) Being in application.cfm, this code runs before each and every page. When I need to change the value of a variable in either the application or session scopes, I change it and duplicate the scope's structure again later on in the page. Which means data is being locked, duplicated, unlocked, locked, set, duplicated, unlocked, etc. 2) Race conditions - Is there ever a time when race conditions exist in this model? It is possible, at times, two pages could be in a rush to set application variables, i.e. two different users are trying to do the same thing at the same time. I am considering putting an additional level of record locking on the application and session scopes, such as a time/date field that would be used in a check to see if anyone overwrote the record since the user last loaded the page. As far as 1) goes, does anyone have some comments on whether or not this is the best way to go about this? As far as 2) goes, has anyone ever tried this before? M ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Another Locking Question
If you are going to put initialization code like this in your Application.cfm file, just be sure that you do not use any code that can generate another HTTP request for another CFM file (such as a cfhttp tag) as you may either create an infinite loop (with a readonly lock) or a deadlock (with an exclusive lock) because your Application.cfm file will keep getting invoked. Christian On Monday, January 13, 2003, at 02:01 PM, Mike Alberts wrote: > Ok, I thought I had the locking thing squared away, but after reading > this thread, I realize that I do not. I was not aware of the potential > problems of using an exclusive lock in the Application.cfm file. > > So ... is this (psuedo) code a reasonable solution? > > Open readonly lock > > If NOT IsDefined(SomeApplicationVariable) > > cfinclude template = "file to initialize app variables" > > close cfif > > close readonly lock > > Mike > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Another Locking Question
You're right. It does create a nested lock situation. Realized this while I was coding it after I posted. So I changed it to this: Open readonly lock cfif NOT IsDefined(SomeApplicationVariable) set AppIsInitialized = "N" else set AppIsInitialized ="Y" close cfif Close readonly lock cfif AppIsInitialized = 'N' cfinclude template="file that sets Application variables" close cfif While I certainly can see the validity in not using the Application scope and putting everything in the Request scope, the only variables that I put in the Application scope are things that only need to be set once and then will never change... things like a default mapping, default application directory, default Verity collection, etc. Then all I ever do within the application is read them, which obviously on requires a readonly lock. I do put my datasource name in the Request scope, to prevent locking every query. Anybody have any comments/issues/flames with using this approach? Mike ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Another Locking Question
No, it isn't, because I presume you'll have an EXCLUSIVE lock in the include file, putting an EXCLUSIVE lock inside a READONLY lock. Bad, bad, bad. We've found using Application variables generally isn't necessary. We include a file in Application.cfm that sets all the global variables we need in the Request scope. > -Original Message- > From: Mike Alberts [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 13, 2003 2:02 PM > To: CF-Talk > Subject: Another Locking Question > > > Ok, I thought I had the locking thing squared away, but after > reading this thread, I realize that I do not. I was not aware > of the potential problems of using an exclusive lock in the > Application.cfm file. > > So ... is this (psuedo) code a reasonable solution? > > Open readonly lock > > If NOT IsDefined(SomeApplicationVariable) > > cfinclude template = "file to initialize app variables" > > close cfif > > close readonly lock > > Mike > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Another Locking Question
Ok, I thought I had the locking thing squared away, but after reading this thread, I realize that I do not. I was not aware of the potential problems of using an exclusive lock in the Application.cfm file. So ... is this (psuedo) code a reasonable solution? Open readonly lock If NOT IsDefined(SomeApplicationVariable) cfinclude template = "file to initialize app variables" close cfif close readonly lock Mike ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Another Locking Question
Yes. Yes. -- Original Message -- From: "Webmaster" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] date: Sun, 12 Jan 2003 15:23:55 -0500 >Hi, > If I reference an APPLICATION var using isDefined, do I have to read lock >it. Is the var really being read? > > > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Another Locking Question
I didn't mean to imply that there wasn't a dumb way to use cflock :D, just that its *proper* use is going to give good results and the reverse can *generally* be counted on to do the opposite. My point was that if you are going to use shared scope vars, lock 'em always. Matt Robertson [EMAIL PROTECTED] MSB Designs, Inc. http://mysecretbase.com -Original Message- From: Sean A Corfield [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 12, 2003 2:00 PM To: CF-Talk Subject: Re: Another Locking Question On Sunday, Jan 12, 2003, at 13:23 US/Pacific, Matt Robertson wrote: > I have yet > to see any instance where locking instituted any noticeable performance > penalty at any level. If you lock within Application.cfm, you will single-thread your application and it will not scale. For low-traffic applications, that may be fine. Sean A Corfield -- http://www.corfield.org/blog/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Another Locking Question
On Sunday, Jan 12, 2003, at 14:20 US/Pacific, Jochem van Dieten wrote: > Sean A Corfield wrote: >> If you lock within Application.cfm, you will single-thread your >> application and it will not scale. For low-traffic applications, that >> may be fine. > I think that is a bit of an oversimplification. Maybe it is a good idea > to distinguish between readonly and exclusive locks and between > different scopes. True. My bad. I was in a hurry. cflock type="exclusive" on every request will single-thread your application. cflock type="readonly" will not. However, to avoid race conditions, you may still need to use exclusive locks - you just have to be careful about it (Marcello's great tip on this is in my blog entry). ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Another Locking Question
I got a tip previously on cf-talk that advised me to do this in my application.cfm: Is this good or bad? (My sites typically have between 10 and 200 connections.) > >Sean A Corfield wrote: > > On Sunday, Jan 12, 2003, at 13:23 US/Pacific, Matt Robertson wrote: > > > >>I have yet > >>to see any instance where locking instituted any noticeable performance > >>penalty at any level. > > > > > > If you lock within Application.cfm, you will single-thread your > > application and it will not scale. For low-traffic applications, that > > may be fine. > >I think that is a bit of an oversimplification. Maybe it is a good idea >to distinguish between readonly and exclusive locks and between >different scopes. >But if we are talking performance penalties, single-threaded sessions >are evil. > >Jochem > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Another Locking Question
Sean A Corfield wrote: > On Sunday, Jan 12, 2003, at 13:23 US/Pacific, Matt Robertson wrote: > >>I have yet >>to see any instance where locking instituted any noticeable performance >>penalty at any level. > > > If you lock within Application.cfm, you will single-thread your > application and it will not scale. For low-traffic applications, that > may be fine. I think that is a bit of an oversimplification. Maybe it is a good idea to distinguish between readonly and exclusive locks and between different scopes. But if we are talking performance penalties, single-threaded sessions are evil. Jochem ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Another Locking Question
On Sunday, Jan 12, 2003, at 13:23 US/Pacific, Matt Robertson wrote: > I have yet > to see any instance where locking instituted any noticeable performance > penalty at any level. If you lock within Application.cfm, you will single-thread your application and it will not scale. For low-traffic applications, that may be fine. Sean A Corfield -- http://www.corfield.org/blog/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Another Locking Question
While there arguably are circumstances where you don't need to lock, if you just do it always, everywhere (subject to the smart use of temp vars as was pointed out already), your code will work properly. I have yet to see any instance where locking instituted any noticeable performance penalty at any level. Just Say Yes to CFLock... Always and Forevermore. :-) Matt Robertson [EMAIL PROTECTED] MSB Designs, Inc. http://mysecretbase.com -Original Message- From: Webmaster [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 12, 2003 12:24 PM To: CF-Talk Subject: Another Locking Question Hi, If I reference an APPLICATION var using isDefined, do I have to read lock it. Is the var really being read? ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Another Locking Question
- Original Message - From: "Webmaster" <[EMAIL PROTECTED]> > If I reference an APPLICATION var using isDefined, do I have to read lock > it. Is the var really being read? --- Yep - if you're not on CFMX, even IsDefined("sharedScope.varName") needs a lock around it. If you need to reference this more than once in a template, of course, set a temp variable: Gyrus [EMAIL PROTECTED] work: http://www.tengai.co.uk play: http://norlonto.net PGP key available ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Another Locking Question
On Sunday, Jan 12, 2003, at 12:23 US/Pacific, Webmaster wrote: > If I reference an APPLICATION var using isDefined, do I have to read > lock > it. Is the var really being read? No, but... If you are trying to avoid a race condition, you may need to lock. See my blog entry: http://www.corfield.org/blog/2003_01_01_archive.html#87048759 Sean A Corfield -- Director, Architecture Web Technology Group -- Macromedia, Inc. tel: (415) 252-2287 -- cell: (415) 717-8473 aim/iChat: seancorfield -- http://www.macromedia.com An Architect's View -- http://www.macromedia.com/go/arch_blog ColdFusion MX and JRun 4 now available for Mac OS X! http://www.macromedia.com/go/cfmxosx ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Another Locking Question
Hi, If I reference an APPLICATION var using isDefined, do I have to read lock it. Is the var really being read? ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4