Coldspring/Multiple Application Scopes due to Loadbalancing

4 views
Skip to first unread message

ElKlaaso

unread,
Jun 4, 2010, 4:44:29 AM6/4/10
to ColdSpring-Users
Hi,

Im making a website for a company who uses virtual servers over which
my application will be loadbalanced.
The application scope wont be shared between these servers and my
website may run on any of them.

Im not sure if this is the reply place for this question, i wonder if
coldspring can help me with it.

Singletons should be stateless they say
Non-singeltons have state.

But, i have a singleton, that can access a tree in the database and
has all kinds of methods to work on that tree.
I noticed this was slow, so i implemented a cache in this tree.
If a write-method (edit,add,delete) is called then it will reload from
database.
This works only, if this tree is the only instance around.
Coldspring puts this tree singelton in the application scope right?

So now, in this loadbalanced-situation, i suddenly can have multiple
trees that represent the same tree, and this will cause some not to be
updated.

This seems to be a singelton that has state, becauses it has a
cache.. did i do something wrong?

I want to keep this tree a singleton, and it seems to make sense to
solve this as low-level as possible..
Im not to lazy to make some extension to coldspring.

I was thinking about having a table in which i mark singleton beans to
be reloaded. But for this i need toknow the internal state of the tree
(if one is modified), which makes me think coldspring should not take
care of this.

Any of you guys know a good, clean, solution?

greets,
klaas

Chris Blackwell

unread,
Jun 4, 2010, 6:03:45 AM6/4/10
to coldspring-users
It seems to me that you've hacked around the problem of having a poorly performing data model by implementing caching, and now you're trying to hack your way around the problems of caching in a distributed environment, when really what you should be asking yourself is why is; why is my data model performing so slowly and what can i do about it?

If your tree data model gets many more writes than reads i'd look at using the nested set model rather than an adjacency list.  This article http://dev.mysql.com/tech-resources/articles/hierarchical-data.html has some useful information on how to manage hierarchical data efficiently.

Cheers, Chris


--
You received this message because you are subscribed to the Google Groups "ColdSpring-Users" group.
To post to this group, send email to coldspri...@googlegroups.com.
To unsubscribe from this group, send email to coldspring-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/coldspring-users?hl=en.


Klaas-Jan Winkel

unread,
Jun 4, 2010, 6:13:49 AM6/4/10
to coldspri...@googlegroups.com
Hi, 

Man, can you please ask some questions before you jump to conclusions, i have hacked nothing. This data model is very simple: Category[id,name] and CategoryRelation[childid,parentid] table. Queries take in the range of a few milliseconds.

I have checked the nested set model, and i could not do with it what i wanted. I need to store a graph with 1 source node (in mathematical terms). 

Also i have more reads then writes, why would i otherwise cache it for reading? It would only get slower if i had more writes.

The tree cfc, like any should have, has a getNode(id) and getNodeChildren(id) method for example.. both these methods do one database query, which is not where the tree cfc gets slow. Maybe i should look into it, it used reactor for database access, maybe not so good idea.

Also, the tree's i have can be very big, for example i have downloaded a huge amount of amazon categories in a tree (this is why i needed the graph capability), and i have a tree with all countries and regions.

greets,
klaas
--
Don't drink and park, accidents cause people

Klaas-Jan Winkel

unread,
Jun 4, 2010, 6:14:53 AM6/4/10
to coldspri...@googlegroups.com
Ow yeah, all the trees im using, have almost no writes at all... after they are set up, thats it, for a long time (years).

Klaas-Jan Winkel

unread,
Jun 4, 2010, 6:15:21 AM6/4/10
to coldspri...@googlegroups.com
oops.. so maybe i should not worry to much about this caching.

Mark Mandel

unread,
Jun 4, 2010, 6:21:24 AM6/4/10
to coldspri...@googlegroups.com

If you are doing caching across clusters, you should really look.at a clustered cache like EhCache or memcache for your needs.

Really, your issue is that the application scope is per server, which is not a coldspring issue per se, but just how cf applications are architected.

Sent from my mobile device

On 4 Jun 2010 20:15, "Klaas-Jan Winkel" <k.wi...@gmail.com> wrote:

oops.. so maybe i should not worry to much about this caching.



On Fri, Jun 4, 2010 at 12:14 PM, Klaas-Jan Winkel <k.wi...@gmail.com> wrote:
>

> Ow yeah, all the...

Chris Blackwell

unread,
Jun 4, 2010, 7:29:28 AM6/4/10
to coldspring-users
I wasn't jumping to conclusions, you yourself said  "I noticed this was slow, so i implemented a cache..."
If its not slow then the need for caching is reduced, however if the data will not change during the lifespan of the application then theres no point making repated calls to the db, so why can't each application cache its own instance of the tree.  If the data changes you would just need to each instance to refresh its cached copy

Or as Mark suggests, look into a distributed cache, but why over complicate things ?

Chris


--

Sean Corfield

unread,
Jun 4, 2010, 12:09:53 PM6/4/10
to coldspri...@googlegroups.com
On Fri, Jun 4, 2010 at 1:44 AM, ElKlaaso <k.wi...@gmail.com> wrote:
> The application scope wont be shared between these servers and my
> website may run on any of them.

That's the root of your problem.

If you put ColdSpring in application scope, your singletons will be
per-server by definition.

The solution is to use a distributed (shared) cache on your cluster
and put the ColdSpring instance in that (assuming you can find one
that will be able to replicate CFML objects correctly) or put your
singletons directly into that cache (probably easier).

That's just a basic ColdFusion architecture issue: scopes are not
shared across servers.

FWIW, Railo supports distributed caches for objects, templates,
queries and the ram:// VFS.
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

David J Henry

unread,
Jun 11, 2010, 10:30:57 AM6/11/10
to ColdSpring-Users
I remember seeing something (on Sean's blog if memory serves) using
Transfer ORM caching with JMS between servers to let each instance of
know when data had gotten stale.

Ah yes, here we are: http://corfield.org/blog/index.cfm/do/blog.entry/entry/Transfer_Cache_Synchronization_in_a_Cluster

Would that solve your problem?

On Jun 4, 12:09 pm, Sean Corfield <seancorfi...@gmail.com> wrote:
> On Fri, Jun 4, 2010 at 1:44 AM, ElKlaaso <k.win...@gmail.com> wrote:
> > The application scope wont be shared between these servers and my
> > website may run on any of them.
>
> That's the root of your problem.
>
> If you put ColdSpring in application scope, your singletons will be
> per-server by definition.
>
> The solution is to use a distributed (shared) cache on your cluster
> and put the ColdSpring instance in that (assuming you can find one
> that will be able to replicate CFML objects correctly) or put your
> singletons directly into that cache (probably easier).
>
> That's just a basic ColdFusion architecture issue: scopes are not
> shared across servers.
>
> FWIW, Railo supports distributed caches for objects, templates,
> queries and the ram:// VFS.
> --
> Sean A Corfield -- (904) 302-SEAN
> Railo Technologies, Inc. --http://getrailo.com/
> An Architect's View --http://corfield.org/

Tom Chiverton

unread,
Jul 8, 2010, 4:57:34 AM7/8/10
to coldspri...@googlegroups.com
Do I misremember Railo having a 'cluster' scope that handles all that for you ?
--
Tom
Reply all
Reply to author
Forward
0 new messages