Inhalte aufrufen

Profilbild

Multi-Tenant

Multi=Tenancy

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
8 Antworten zu diesem Thema

#1 jnicke

jnicke

    Newbie

  • Members
  • 6 Beiträge

Geschrieben: 16 July 2022 - 19:06

I just installed Smartstore 4 with no issues.

I am interested in provisioning Smartstore as multi-tenant.  I noticed a "App_Data/Tenants/Default" folder.  Is there documentation or blog that explains on the configure multiple tenants?  Let me know how to proceed.

Thanks!

 



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3696 Beiträge

Geschrieben: 18 July 2022 - 20:42

This is a simple tenant system to be able to switch between different tenants within an installation. In "App_Data\Tenants" there is a file "current.txt" which contains the name of the current tenant to use. "Default" is the default name. All tenant-related files reside in the subfolder with that tenant name. So, the default tenant folder is "App_Data\Tenants\Default". The application stores all tenant-related files in the tenant folder, including the Settings.txt file with the connection string to the tenant database.

Schöne Grüße aus Düsseldorf,
Marcus Gesing


#3 jnicke

jnicke

    Newbie

  • Members
  • 6 Beiträge

Geschrieben: 19 July 2022 - 04:32

Thanks for the info! If I wanted to use something other than "Default" in the case where I want multiple tenants, Is it possible if I set var curTenant to a different tenant name/folder?  The idea is to insert the tenant connect-string at run-time, thus multi-tenant.

var curTenant = ResolveTenant();
  var tenantPath = "~/App_Data/Tenants/" + curTenant;

 

(From dataSettings.cs).

 

Thoughts?

 

#4 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3696 Beiträge

Geschrieben: 19 July 2022 - 15:29

Probably no one has tried this before, but why not?


Schöne Grüße aus Düsseldorf,
Marcus Gesing


#5 jnicke

jnicke

    Newbie

  • Members
  • 6 Beiträge

Geschrieben: 22 July 2022 - 14:59

So I tried it.  setting var CurTenant = "Tenant2" (in dataSetting.cs); works.  A new Tenants directory is created with a tenant specific connect-string in the settings.txt.

 

Now I am trying to figure out how to set CurTenant based on the requesting url so that http://tenant2.mystore.com would set to "tenant2".  This appears to be all we need to make SmartStore multi-tenant.  Any advice on how do to this in the Smartstore project would be much appreciated.



#6 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1114 Beiträge

Geschrieben: 25 July 2022 - 19:03

I'm afraid there is much more to do:

  • Super level, database independent tenant management
  • A new tenant scope for dependencies (Singleton --> Tenant --> Request)
  • Installing/activating plugins & themes on tenant level
  • Serving custom templates/views on tenant level

This all is a heavy load of work, which is the reason why we haven't implemented it yet. All we have now is a comfort mechanism for developers: decide on app startup which tenant to load. Means: 1 instance = 1 tenant. But real multi-tenancy means: 1 instance = many tenants.


Murat Cakir
SmartStore AG


#7 jnicke

jnicke

    Newbie

  • Members
  • 6 Beiträge

Geschrieben: 28 July 2022 - 19:18

I defer to your expertise.  But I want to point out / inquire about the C:\MTA\SmartStore\App_Data\Tenants\Default directory (one for each tenant, this tenant is "Default").

 

The Default tenant directory has these files.  It appears plug-ins, themes, custom views, etc. are stored and managed in the Tenant directory. I can deal with this.

If my idea is correct, if I could set var-curTenant at run-time (having already created the Tenant Directory from a template), I could have autonomous tenants using the same instance of the app.   Thoughts?

Directories:
AssetCache
Hash
Media
Sitemaps
temp

Files:
InstalledPlugins.txt
plugins.assemblies
plugins.hash
Settings.txt



#8 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1114 Beiträge

Geschrieben: 29 July 2022 - 18:34

It appears plug-ins, themes, custom views, etc. are stored and managed in the Tenant directory

 

This is NOT the case. That would have to be developed first.

 

if I could set var-curTenant at run-time

 

Of course you can...

 

I could have autonomous tenants using the same instance of the app

 

... but, no. Because: one instance (aka process aka AppDomain) = ONE TENANT! That is how it works at the moment. You just switch to any tenant during app start. But AFTER app start, you can't switch this tenant anymore.


Murat Cakir
SmartStore AG


#9 jnicke

jnicke

    Newbie

  • Members
  • 6 Beiträge

Geschrieben: 29 July 2022 - 21:26

Thanks for responding.....  Maybe in a future release you will support the multi-tenant use-case.  It looks like much of the architecture is done.