Hi Jeff,

Its not necessarily a bad way to do it, but it does depend on how many
domains you've got and how much ram you have :)   It may be that a little
refactoring could save you a lot of overhead though.

I've built sites that served many domains from a single cf application in
the past, although not recently with MG.  The way i chose to do it was to
have a single instance of the application which determined its siteID at the
begining of the request and then passed this into any method calls to the
service layer that were site specific.

If you're instantiating your service cfc's manually in the init method of
your controller, then are you having to create duplicate instances of the
same service cfc in multiple controllers?  That would be a waste of
resources.  If you take the approach i've outlined above you could then move
your service cfc's out of modelglue into a parent coldspring factory, and
use the MG3's bean injection [1] facility to provide your controllers with
the services they need.  As a handy side effect this will allow you to
restart your mg app without having to re-instantiate all of your services.

There's probably 99 other ways to approach this though :)

Chris

[1]
http://trac.model-glue.com/wiki/HowTos/HowToUseBeanInjection#BeanInjection



On 23 July 2010 19:27, jeff <[email protected]> wrote:

> As my application scales, my ram keeps getting eaten up.  And based on
> the traffic coming to the server, I wonder If my architecture needs
> some adjustment to function better.
>
> Basically this is how things work:
> There are lots of domains all configured to use this same model-glue
> application.  The magic happens in the init() function in the
> controller where I figure out which domain is being loaded, and then I
> load ALL the cfcs into the variables scope like this:
>
> <cffunction name="Init" access="Public" returnType="Controller"
> output="false" hint="I build a new SampleController">
>  <cfargument name="ModelGlue" required="true"
> type="ModelGlue.ModelGlue" />
>  <cfargument name="InstanceName" required="true" type="string" />
>  <cfset super.Init(arguments.ModelGlue) />
> <!--- Turns out we don't need this after all.  We'll keep it here just
> in case we do down the road.
>        <!--- get the model glue coldspring global config bean --->
>        <cfset var mgConfig =
> getModelGlue().getBean("modelGlueConfiguration") />
>        <!--- grab the variables we'll need to reload the site. (this is
> used
> when resetting themes!) --->
>        <cfset variables.reloadKey = mgConfig.getReloadKey() />
>        <cfset variables.getReloadPassword = mgConfig.getReloadPassword() />
>  --->
>
>        <!--- Get all of our app settings --->
>        <cfset var appSettings = getModelGlue().getBean("appSettings") />
>
>        <!--- load config settings here --->
>        <cfset variables.dsn = appSettings.getConfigSetting("dsn") />
>
>        <!--- Load up the site configuration settings here --->
>        <cfset variables.siteSettingsCFC = createObject("component",
> "model.siteSettings").init(variables.dsn,cleanURL(CGI.SERVER_NAME)) />
>        <cfset variables.siteID = variables.siteSettingsCFC.getSiteID() />
>
>        <!--- database interaction CFCS --->
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>        <cfset variables.exampleCFC = createObject("component",
> "model.example").init(variables.dsn,variables.siteID) />
>
>
>  <cfreturn this />
> </cffunction>
>
> -------------------------
>
> After this occurs we basically have an isolated model-glue application
> loaded for each domain, which makes it easy to keep all the data
> separate.  But I am now wondering if this is eating up all the memory
> and there is a better way to design my application; perhaps creating
> the objects on demand instead of instantiating them into memory in the
> init().
>
> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<model-glue%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en
>

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to