-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OrchardCore Clusters #13633
OrchardCore Clusters #13633
Conversation
@sebastienros Just for info
Already too much questions, I will think about it ;) When I will have time, as a first step I will try the Yarp in memory configuration that allow to update dynamically the Yarp config by passing Routes and Clusters, maybe make it easier by exposing a kind of Destinations provider interface, so that when the list of Destinations change we update the config. |
# Conflicts: # OrchardCore.sln # test/OrchardCore.Tests/Shell/ShellHostTests.cs
# Conflicts: # src/OrchardCore/OrchardCore.Abstractions/Shell/ShellSettings.cs # src/OrchardCore/OrchardCore/Modules/ModularTenantContainerMiddleware.cs # src/OrchardCore/OrchardCore/Modules/ModularTenantRouterMiddleware.cs # test/OrchardCore.Tests/Modules/OrchardCore.Tenants/Services/TenantValidatorTests.cs # test/OrchardCore.Tests/Shell/ShellHostTests.cs
# Conflicts: # src/OrchardCore.Build/Dependencies.props # src/OrchardCore/OrchardCore/Modules/ModularTenantRouterMiddleware.cs
# Conflicts: # src/OrchardCore/OrchardCore.Abstractions/Shell/Builders/ShellContext.cs
# Conflicts: # OrchardCore.sln # src/OrchardCore.Build/Dependencies.props # src/OrchardCore.Themes/TheAdmin/Views/Layout-Login.cshtml # src/OrchardCore/OrchardCore/Modules/ModularTenantRouterMiddleware.cs
This pull request has merge conflicts. Please resolve those before requesting a review. |
@Piedone is this related to Lombiq? If yes can anyone else continue on this, otherwise what's the progress? |
Nope, and we haven't worked on this with JT. It would be useful though for multi-node hosting. |
It seems that this pull request didn't really move for quite a while. Is this something you'd like to revisit any time soon or should we close? Please comment if you'd like to pick it up and remove the "stale" label. |
Closing this pull request because it has been stale for very long. If you think this is still relevant, feel free to reopen it. |
Fixes #13636
Distributes requests across tenant clusters by using the Microsoft Yarp.ReverseProxy.
Work in progress but some first info.
We first use the Yarp Configuration allowing to define
Routes
andClusters
with many options. Each Route is tied to a Cluster composed ofDestination(s)
on which load balancing can be applied ...We only need one
catch-all
RouteTemplate
and multipleClusters
on which we can configure a customSlotRange[min, max]
property (up to 16384 slots).Each Tenant has an unique slot hash, so an unique
Slot
and then belongs to theCluster
having the slot in itsSlotRange
, theCluster
having multipleDestination(s)
. Note: We could have used aCluster
havingNodes
but we follow the Yarp Config having aClusters
list ofCluster
type.The same application can run as a proxy or behind it (we check the headers), the advantage with our distributed services, is when as a proxy we are still aware of all tenants data. So on a request we can use the same
RunningShellTable
to know the Tenant, then select the rightCluster
based on the Tenant slot hash (in a custom middleware), and letYarp
select one of itsDestination(s)
.To compute a Tenant slot hash we use the
CRC-16/XMODEM
algorithm (as Redis use for clustering keys) applied on the newTenantId
property, it allows to automatically spread out new tenants on the slots and then on the configuredClusters
. This knowing that theCRC-16
is fast to compute and always return the same number for the sameTenantId
, so a tenant stays on the sameCluster
.The distribution is not perfect with few tenants but gets better and better as the number increases.
TODO: Also coupled to a simple feature allowing to release a Tenant if not requested since a given time.