views:

776

answers:

5

Hi all,

We have a number of web servers, each running one version of Coldfusion. The cluster has a load balancer on front of it.

Obviously each of these servers has it's own CF application running and this implements query caching at the CF application level. However, since all of these servers service the one web application, many of these cached queries are duplicated across CF application instances.

Is there any way to implement query caching at the web application level, i.e. across many CF instances. Or if there is not, is there a better way to set up our cluster to minimise load on our database server?

I hope I made myself clear :)

Cheers, Ciarán

+3  A: 

You might consider giving memcached a try.

Patrick McElhaney
Thanks. I'll check this out - I have a million and one questions about it but I'll read the FAQs first :-P
Ciaran Archer
We are also looking closely at EHCache (http://ehcache.sourceforge.net/) as an in-process alternative.
Ciaran Archer
+2  A: 

I would look at memcached - there is an open source project for integrating it in ColdFusion here: cfmemcached.

If you happen to be using Railo, I've heard that it also has a "cluster" scope.

If neither of those are available or appeal to you, you could alternatively set up one of your servers to handle the queries you want to cache and then fetch them from that server directly via a webservice. That way you can cache them on just the one server, which will reduce the memory footprint across the cluster and also reduce the frequency of access to the db server. You might want to take the server that's handling the query caching out of the cluster however and simply dedicate it to the query caching and anything else you want to off-load from the front-facing machines while the others handle outside traffic.

Isaac Dealey
A: 

you can cluster across and have the application scope shared across the servers, but you must be using the enterprise version of ColdFusion. More information here: http://livedocs.adobe.com/coldfusion/7/htmldocs/00001774.htm

Ryan Guill
A: 

The session scope can be clustered in ColdFusion, if you turn on j2ee sessions. But all a clustered scope does is copy the data across the servers. So the queries would still be copied on all 3 servers. So you would be back to where you are now.

However, I would just use the CachedWithin attribute of cfquery instead of using the application scope. This way you are letting the CF engine do the actually cache management. Keeping memory from getting out of hand, and you don't add the overhead of copying lots of data between servers.

In regard to using cachedWithin: main problem with per-server caching is it still mean the same query executed many times against the database. Decided to use EHCache on each of our web servers, as it allows partial page caching and can be extended to a centralised cache server i.e. like memcached.
Ciaran Archer
+1  A: 

Decided to use EHCache on each of our web servers, as it allows partial page caching and can be extended to a centralised cache server i.e. like memcached. Very happy with it so far.

Many thanks for all the suggestions!

Ciaran Archer