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

  1. create table named "tenantsettings" holds tenant specific settings
  2. create table named "usersettings" holds user specific settings
  3. identify tenant post login , when first time tenant settings, store tenantsettings cache [distributed or in-memory syc'ed via pub-sub]
  4. also, post login of user, fetch usersettings , put in cache [same in 3]
  5. 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

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -