Skip to content

Configuring sharding

Jon P Smith edited this page Aug 10, 2023 · 11 revisions

The SetupMultiTenantSharding extension method optionally takes in a ShardingEntryOptions class via its defaultShardingEntry property. The ShardingEntryOptions class has a boolean property called hybridMode in its construction that allows you select Hybrid mode via a true, or Sharding-Only mode if false.

If the SetupMultiTenantSharding,s defaultShardingEntry is null, then it create a sets the hybridMode to false, thus selecting sharding-only mode (See Example7's Program class. If you want to select hybrid mode, then you need to provide a new ShardingEntryOptions with the hybridMode to true in the constructor.

What do the hybrid and sharding-only mode do?

Here is a list of what they do, and want is the result of being in each mode.

Hybrid selected (hybridMode == true)

  • The "DefaultConnection" connection string, which provides the database use by AuthP's to hold its data, is shown in the list of connection strings available to add sharing tenants.
  • On the first deployment of your multi-tenant application to a new web server, then a default sharding entry (see the How AuthP handles sharding document on sharding entries are) is added to the sharding entries and linked to the "DefaultConnection" connection string. This default sharding entry allows you immediately add sharing tenants to the database defined by the "DefaultConnection" connection string.

What is the result of being in Hybrid mode?

When in hybrid mode the first deployment the application sets up connection strings and a sharding entry that allows a new shared tenant without need to manually set up a sharding entry. This also me to create a example of using sharding in the AuthP repo called Example6, which you can run to try it out, including demo users and tenants via AuthP's Bulk load feature.

Sharding-Only selected (hybridMode == false)

  • The "DefaultConnection" connection string is not listed in the connection strings available to add sharing tenants, unless the "DefaultConnection" connection string is the only connection string. This useful because:
    • If you add connection strings linked to different servers, they are shown and the "DefaultConnection" connection string isn't (see Example7's appsettings.json file.
    • But only want one server, found by the "DefaultConnection" connection string, then this will work without providing any other connection strings.
  • On the first deployment of your multi-tenant application to a new web server the list of sharding entries is empty.

What is the result of being in Sharding-Only mode?

Because you have sharding-only tenants and the Service for shard-only tenants code its very easy to create / delete tenants. Therefore its better to NOT have pre-configured like the hybrid mode and on first deployment the application. This means you application starts there will no tenants orsharding entries (see the How AuthP handles sharding document for sharding entries), but it is very simple to add a new tenant.

Additional resources

Articles / Videos

Concepts

Setup

Usage

Admin

SupportCode

Clone this wiki locally