We used to blog more before twitter came along.
Scope sync in a cluster
Perennial problem...trying to solve it here without doing TOO much funky work.
Here's the deal:
We're working on a Farcry project. It's going to be deployed to a cluster. Two servers with 2 instances of CF on each. They are cross-paired.
Server1-instance1 is paired with server2-instance4. Server1-instance2 is paired with server2-instance3.
Farcry uses the application scope to cache up a lot of goodies to make the system run faster. This is perfectly acceptable and desirable. Problem is. when the content of the site is updated...how do we force a refresh of the cache in each instance?
First thought was to use an event gateway. Use an extended stored procedure in the database (we're using SQL Server 2005) to make a call to an event gateway that would "do stuff".
Our next move was to look at each other and say "we've never tried that before" followed shortly thereafter by "does that make any sense to push that logic down into the database?"
The next thought was to put a hook in to the fourq database interface code to watch for updates to certain content types. The ones we were most concerned about were refFriendlyURL and config tables. When we detect a change. we'll fire off a cfc method to update a new table in the database with one row per instance containing a bit field ("dirtyFlag").
We'll make a change to Application.cfm in the root of the Farcry site to always do a quick check of that table. Grab the instance running the current request. check the table row for that instance. If the flag is set. update application scope. set the flag back to 0. and then continue on.
Just re-read all that and realized a database trigger on those tables could just as easily set the dirty flags too. Hmph.
Anyone see any issues with this approach? The application scope. if dirty. is updated by each instance as each instance is hit with a request immediately after being set as dirty. Seems efficient enough to me!

