c# - Loading the tenant specific variables in a multi tenant application -
i have mvc application multi tenant architecture. in this, there global variables (common users of every tenant) , specific logged in user. also, there settings common users of specific tenant.
i storing , retrieving global , session variables mentioned below.
- specific logged in user -
httpcontext.current.session["sessionvariablename]. these variables loaded @ time login of user. - global variables -
httpcontext.current.application["applicationvariablename"]. these variables loaded in global.asax on application startup.
now have question, how load tenant specific variables. in event need load vaiables? not want load tenant specific variables @ time of application startup many tenant may not using application. also, may overhead @ time login of each user check , load tenant specific settings. best approach ?
in case, suggest following approach
- create table named "tenantsettings" holds tenant specific settings
- create table named "usersettings" holds user specific settings
- identify tenant post login , when first time tenant settings, store tenantsettings cache [distributed or in-memory syc'ed via pub-sub]
- also, post login of user, fetch usersettings , put in cache [same in 3]
- do not use application memory because cache may accidentally polluted , not scale load
database entity details
1. tenantsettings following can columns tenantsettings
- tenantid
- settingid
- settingvalue
- auditfields createdby, createdon, isactive, updatedby...
2. usersettings
- userid
- tenantid
- settingid
- settingvalue
- audit fields similar above
hope helps.
Comments
Post a Comment