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]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en