Complicatated way of saying can i run more than one cf instance per site per box.
The issues when we thought about this is the use of fwreinit. Obviously this would effect only the instance your looking at and not the others.
Other than restarting both instances is there a better way?
The answer is yes, but I am confused by your definition of instance.
ColdFusion uses application names to separate application scopes, that in turn says that website is different to another running on ColdFusion. ColdBox is no different, and if you are asking can two or more websites run the same ColdBox, the answer again is yes.
The solution is to move Coldbox to a shared location and reference this in your application.cfc, from here as long as you have a unique application name for your application then they are seen as different instances as you have out it.
Was that what you wanted to know?
Dont think thats the issue.
We have multiple sites each running on thier own cf instance (jvm), each is a different application with a different application name.
What i want to do is run 2 instances as a cluster for a single site. So the site will be spread over 2 jvm instances but iis will see them as the same site.
But the problem here is that when you view the site you get one of the instances and so if you do an fwreinit=1 it will only affect that one instance and not affect the other, thus the site is only have re inited.
Ok that makes a bit more sense, I have no experience in this so I might leave it to others. But I am sure there are some tricks you can do, like write a template to cycle the instances for example.
One trick I always use is the application name, I always append to the name the date so it looks something like this.
this.name = “applicationName 2012.05.03.0001” the last four digits is a revision number in case I make more than one change to the application in the day. Maybe not the best approach but it does work, and I am sure that there are other better methods.
That is correct. The same happens when you are running CF on a cluster…
Suppose server one has the app running and server two as well. Load balancing will determine what server is being used at any given request.
So you can never be sure which instance is being reinitialized.
The only solution for that is to log in to each server individually and use the local browser to reinit your app.
I do not know how you would do that if you have 2 jvm instances running on the same server though…
It might be as easy as editing hosts file (if using windows) and add two instances to localhost with a different port and let the port decide what instance to call.
Your cluster manager (load balancer) would basically be doing something similar…
We have exactly the same setup here and the way we got around this was thanks to this simple little Interceptor:-
Basically this Interceptor checks for a date stamp change on every request. If one is found then at the end of that calling request Coldbox is told to reinitialise and updates the time stamp.
We’re using ANT for automated deployment so we get that to swap a token inside the Interceptor for the time of the deployment.
If you’re not using automation then another option could be to have the date field in a database. You update that and each checking instance will react to the change once it sees it.
That is a pretty nifty setup
We spent many a year with the same dilemma :-).
Caching / application scope management within CF clustering is a complete nightmare! Synccing is something we’ve been asking for on the feature wishlist for about 3 versions now and still no sign so here’s hoping now that JRun has gone they do something about it,
The DB route does mean a performance hit but compared to the manual work headache it’s a real time saver and the CB Interceptor really complements that as well
Deployment is semi automated via a CF Builder extension that publishes files that are changed in subversion. We give the developer the option of reiniting or not. Possibly we can create a dummy file that is placed on the file system when the changed files are uploaded that the interceptor includes that contains the new code/token as you guys do it. Problems are if we need to do an ad hoc reinit without code uploads. In which case possibly upon an fwreinit to one of the instances it generates the file that that other instance picks up? Better still puts a token in the db then the other sites on the other boxes will reinit too. Sound like a plan?
You’re welcome and yeah the DB approach seems like the best case. It certaintly sounds the most consistent approach anyway.
If you need to reinitialise then change the token in the database and a quick page refresh on each instance should kick the interceptor off.