[Coldbox 3.8.1] Caching the whole applicaiton.Coldbox

Hi guys,

I’m having a little experiment with trying to cache our whole Coldbox application, eventually the idea is then to distribute the cache so many servers can ‘get’ a copy of the application without having to init it.

Just using Coldfusion’s built in caching stuf, it looks easy enough to store all the objects, but after retrieval I immediately get an error: 'Cache template is not registered. ', from Coldbox. This goes away with a re-init, but that obviously negates the point of this exercise!

Does anybody have any ideas, or pointers, am i completely miss-understanding ehCache (or Coldbox), or is this a weird, but viable, idea?

Many Thanks,

Alex

Hi Alex,

I would suggest to follow these guides for caching the Application data across multiple server.

Deploy Interceptor
This interceptor reads and stores a_deploy.tag file to check for new deployments to a server or server cluster.
http://wiki.coldbox.org/wiki/Interceptors:Deploy.cfm

CacheBox: The Enterprise ColdFusion Caching Engine, Aggregator and API
It is part of the ColdBox3+ Platform but it can also function on its own as a standalone framework
http://wiki.coldbox.org/wiki/CacheBox.cfm

CacheBox Couchbase Provider
The CacheBox Couchbase Provider is an adapter that allows you to connect CacheBox to a Couchbase cluster and then leverage that cluster in your ColdBox applications or any application that leverages CacheBox in its standalone version.
http://wiki.coldbox.org/wiki/CacheBox-Couchbase.cfm

Building High Performance Applications with ColdFusion 9 and Ehcache 2.4
http://java.dzone.com/articles/building-high-performance

I hope this will help.

Thanks
Sana

Hi Sana,

Thanks for this, i’ve been following Rob Brooks-Bilson’s advice, and feel confident about distributing the cache around, when i get there.

The other links you posted all assume that Coldbox has already been loaded and init’d properly, which is where the problem is. I’m trying to get a copy of an existing Coldbox application from cache.

Many Thanks,

Alex

Hi Alex,

Please would you elaborate **"**existing Coldbox application from cache" ???

Sana,

This might be me getting things wrong but i’m trying to do something like:

/* ColdBox */
Application[ColdboxAppVar] = new coldbox.system.Coldbox
( COLDBOX_CONFIG_FILE , COLDBOX_APP_ROOT_PATH , COLDBOX_APP_KEY , COLDBOX_APP_MAPPING );

Application[ColdboxAppVar].loadColdbox();

CachePut(applicationCacheKey,application);

Then, if the cache exists, just get from the cache, rather than running the loadColdbox again.

Many Thanks,

Alex

What do you mean when you say “cache our whole ColdBox application”? What are you putting in the cache?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Hi Brad,

See above, i’m just trying to work out if it’s possible to cache the init’d Coldbox application, because it has quite a large startup ‘cost’, and we’re running in a clustered environment!

Something like:
Application[ColdboxAppVar].loadColdbox();

CachePut(applicationCacheKey,application);

I’m aware that this might not be possible at all…!

Many Thanks,

Alex

Maintenance windows for down time is the best option always.

Hi Andrew,

This isn’t about planned (or unplanned) down time. We have multiple, load balanced, servers running the application (in fact it’s SaaS, so there’s many sandboxed versions of the same application), and whenever a client arrives at a server not running their copy of the application they face a very unpleasant wait whilst the application starts on that server. I want to be able to ‘warm start’ the application from a cache.

Many Thanks,

Alex

So, do we think this just isn’t possible?

Alex

nothing is impossible, it’s more if your approach is practical.

Personally I don’t know enough about your SaaS application to give a definitive solution, but still maintenance windows ring in my ear still. Pull them down for maintenance and update your servers I am sure you already have the replication process done. All you need to add to that is a ping to init each app during this window, once done exit maintenance window.

Sorry Andrew, that still doesn’t solve the issue of the request being load-balanced to a server which is not yet running the application. With 4 servers running, there is a chance that the first 4(!) times I hit the application, each request is just spent waiting for it to start up.

I would have to build a system which inits every copy of the application, on every server, every time that server is started, that’s really going to take a long time. They would potentially be running copies of the application which never get used. Even in our staging environment, that’s 2 clustered servers each running only 4 copies of the application. Obviously each needs to be started, a total of 4 inits, but hopefully they don’t need to be started another 4 times on the second server. The production environment has many more servers, and many, many more client applications.

What i want to do, is if the application has been init’d once, just get that, and run it locally, rather than start a new one.

Many Thanks,

Alex

​And how are you replicating your code changes now?​

The code is all stored in a shared DFS, so there’s only one code set.

Alex, I don’t think caching the entire ColdBox framework in an out-of-process cache is possible. Firstly, most all the core CFCs are set as serializable=false and an out of process cache would require serializing/deserializing the entire object graph. Even if you managed to do this, imagine how impossible concurrency would be since CFML’s entire locking mechanism only applies to that server. How would you reconcile incompatible versions of the framework on two different servers? (think of a source control conflict)

Can you expound on what takes the time to startup your application? I think your time would be better spent improving startup time. If it’s data-related, you can cache specific pieces of data that the framework needs to start. How much time are we talking? Seconds? Minutes? If you’re worried about users being directed to a server that’s not “warmed up” then don’t add it to the load balancer until it’s “warm” and/or configure layer-7 heartbeat probes so the LB doesn’t send traffic to a node that’s not responding.

Thanks!

~Brad

Thanks Brad,

It seems my idea of how this would work is a bit too simplistic. I’ve been taking a look at the startup cost issue, and have come across something really odd, but fairly unrelated to Coldbox…

There is a HUGE gap between the time with the application is initialized, and when onApplicationStart() runs. I’ve been taking a look at this (what i’m doing is logging tick counts throughout the startup), on my local machine it takes about 2 seconds, but in the production environment it’s taking between 15-25 secs before Coldbox is even being started!
As far as i can tell this is all down to ORM, i’ve tried every combination of settings i can think of (using static .hbmxml files not logging anything, etc, etc) nothing seems to reduce the time (but Fusion Reactor always shows the StackTrace to be rolling around in hibernate somewhere). The only thing i can think is that because we have a large number of modules & model files, ORM has to do lots of scanning and mapping to start itself.

I know this isn’t really the right place, but does anybody have any experience with this? Could someone point me in the right direction?

Many Thanks,

Alex

Sounds like the CFC scan location is scanning a large number of files. Show me some of the stack traces pls in Gist.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com