Wednesday, August 20, 2008

Dynamic cfapplication name - Don't do it!

What happens if you use a dynamic name for your cfapplication tag
name=X, is especially if you are using frameworks of any kind, the
more sites you load on top, the memory needs increase X fold. i.e.
coldspring's memory needs + fusebox memory needs + others = Mass
Memory when you have lots of these apps running. Simple right -

It wasn't until we started piling apps on it that this came to life -
the good news is the fix is not complex and doesn't have to mean HIGH
impact changes to your application.

1.) change your cfapplication name value to something static i.e. 'sitex'
2.) I created my site Object that holds the invividual settings for
each client (that was previously stored as it's own application data
object) and used coldspring to wire up that to a siteFactory object
that gives me site Beans based on the domain.
3.) on application start, the siteFactory creates a large structure of
all active site objects 1 time only. Then when the app asks for say
application.site.getName() - it will call the siteFactory, the site
factory gets the data by the domain matching the current domain, and
returns the site object.

With this in place - there was ZERO code changes in the application and the memory requirements have gone WAY down.

No comments: