-
Notifications
You must be signed in to change notification settings - Fork 811
Load balancing backoffice documentation #7545
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
Merged
eshanrnh
merged 28 commits into
umbraco:main
from
nikolajlauridsen:load-balancing-backoffice
Oct 28, 2025
Merged
Changes from 9 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3258116
Add general docs and SignalR
nikolajlauridsen c976614
Fixup SignalR doc
nikolajlauridsen 15eaa32
Add settings documentation
nikolajlauridsen 67ab39d
Add scheduling documentation
nikolajlauridsen 0b29068
Fix some linting
nikolajlauridsen e187796
Update signalR article
nikolajlauridsen 5aa185d
Update capitilization
nikolajlauridsen a359f91
Fix sentences
nikolajlauridsen 69d8f86
Apply suggestions from code review
nikolajlauridsen 6b571b5
Apply suggestions from code review
nikolajlauridsen d8f0fd1
Merge remote-tracking branch 'origin/load-balancing-backoffice' into …
nikolajlauridsen edf87a4
Added Distributed jobs settings article entry to Summary.md file
eshanrnh a387438
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh add8792
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh f36fb86
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh d7debe5
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh 8482136
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh 41bf3c5
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh 78c68be
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh 3becae2
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh 630cc8e
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh f758cfd
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh 5feb2fe
Update 17/umbraco-cms/fundamentals/setup/server-setup/load-balancing/…
eshanrnh 201786f
Update 17/umbraco-cms/reference/scheduling.md
eshanrnh 8409fea
Update 17/umbraco-cms/reference/scheduling.md
eshanrnh 8258d7b
Update 17/umbraco-cms/reference/scheduling.md
eshanrnh e4c3109
Update 17/umbraco-cms/reference/scheduling.md
eshanrnh 37566a9
Update 17/umbraco-cms/reference/scheduling.md
eshanrnh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...cms/fundamentals/setup/server-setup/load-balancing/load-balancing-backoffice.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Load Balancing the Backoffice | ||
|
|
||
| This article contains specific information about load balancing the Umbraco backoffice. Ensure you read the [Load Balancing Overview](./) and relevant articles about general load balancing principles before you begin. | ||
|
|
||
| By default, the Umbraco load balancing setup assumes there is a single backoffice server and multiple front-end servers. From version 17, it's possible to load balance the backoffice. This means there's no need to differentiate between backoffice servers and front-end servers. However, this requires some additional configuration steps. | ||
|
|
||
| ## Server Role Accessor | ||
|
|
||
| Umbraco has the concept of server roles, to differentiate between backoffice servers and front-end servers. Since all servers will be backoffice servers, we need to add a custom `IServerRoleAccessor` to specify this. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Start by implementing a custom `IServerRoleAccessor` that pins the role as `SchedulingPublisher`: | ||
|
|
||
| ```csharp | ||
| public class StaticServerAccessor : IServerRoleAccessor | ||
| { | ||
| public ServerRole CurrentServerRole => ServerRole.SchedulingPublisher; | ||
| } | ||
| ``` | ||
|
|
||
| You can now register this accessor, either in `Program.cs` or via a Composer: | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```csharp | ||
| umbracoBuilder.SetServerRegistrar(new StaticServerAccessor()); | ||
| ``` | ||
|
|
||
| This will ensure that all servers are treated as backoffice servers. | ||
|
|
||
| ## Load balancing Isolated Caches | ||
nikolajlauridsen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| One of the issues with load balancing the backoffice is that all servers will have their own isolated caches. This means that if you make a change on one server, it won't be reflected on the other servers until their cache expires. | ||
|
|
||
| To solve this issue, a cache versioning mechanism is used. This is similar to optimistic concurrency control. Each server has a version number for its cache. When a server makes a change, it updates the version identifier. The other servers can then check the version identifier before accessing the cache. If the cache is out of date, they invalidate it. | ||
|
|
||
| This does mean that the server needs to check this version identifier before a cache lookup. By default, this behaviour is disabled. It's only required when load balancing the backoffice. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| You can enable this on the Umbraco builder, either in `Program.cs` or via a Composer: | ||
|
|
||
| ```csharp | ||
| umbracoBuilder.LoadBalanceIsolatedCaches(); | ||
| ``` | ||
|
|
||
| ## SignalR | ||
|
|
||
| The Umbraco Backoffice uses SignalR for multiple things, including real-time updates and notifications. When load balancing the backoffice, it's important to ensure that SignalR is configured correctly. See the [SignalR in a Backoffice Load Balanced Environment](./signalR-in-backoffice-load-balanced-environment.md) document for information regarding this. | ||
|
|
||
|
|
||
| ## Background Jobs | ||
|
|
||
| If you have custom recurring background jobs that should only run on a single server, you'll need to implement `IDistributedBackgroundJob`. See [Scheduling documentation](../../../../reference/scheduling.md#background-jobs-when-load-balancing-the-backoffice) for more information. | ||
62 changes: 62 additions & 0 deletions
62
.../server-setup/load-balancing/signalR-in-backoffice-load-balanced-environment.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # SignalR in a Backoffice Load Balanced Environment | ||
| When load balancing the backoffice, we also need to take care of the client to server communication outside of web requests. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Umbraco uses SignalR to abstract away these types of communication. This also allows us to support load balancing by replacing how the communication is done by introducing a backplane. | ||
|
|
||
| ## Introducing a SignalR Backplane | ||
| A SignalR backplane is akin to a load balancer for direct client to server web traffic. It keeps track of which client is connected to which server. So that when a client sends a message, it arrives at the right server. It also allows any connected server to send a message to all clients, even those that are not directly connected to it. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Choosing the right backplane | ||
| Choosing the right backplane comes down to a few things | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Message throughput | ||
| - Cost | ||
| - What infrastructure you already have in place | ||
|
|
||
| Microsoft has a good list of available backplanes in its [SignalR load balancing article](https://learn.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-10.0), including a list of well known [third party offerings](https://learn.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-9.0#third-party-signalr-backplane-providers). | ||
|
|
||
| ## Code examples | ||
| The following code examples show you how you can activate SignalR load balancing using an Umbraco composer. | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| {% hint style="info" %} | ||
| Both Umbraco and these composers use `.AddSignalR()`. This duplication isn't a concern as the underlying code registers the required services as singletons. | ||
| {% endhint %} | ||
|
|
||
| ### Using existing infrastructure | ||
| It is possible to use your existing database as a backplane. If this database is hosted in Azure it is not possible to enable Service Broker which will have an impact on message throughput. Nevertheless, it might be sufficient to cover your needs. | ||
| For more information, check out the [GitHub page](https://github.com/IntelliTect/IntelliTect.AspNetCore.SignalR.SqlServer). | ||
| - Add a reference to the IntelliTect.AspNetCore.SignalR.SqlServer NuGet package | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Add the following composer to your project | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```csharp | ||
| using Umbraco.Cms.Core.Composing; | ||
|
|
||
| namespace Umbraco.Cms.Web.UI.SignalRLoadBalancing; | ||
|
|
||
| public class SignalRComposer : IComposer | ||
| { | ||
| public void Compose(IUmbracoBuilder builder) | ||
| { | ||
| var connectionString = builder.Config.GetUmbracoConnectionString(); | ||
| if (connectionString is null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| builder.Services.AddSignalR().AddSqlServer(connectionString); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Azure SignalR Service | ||
| - Setup a resource as described in the [Microsoft tutorial](https://learn.microsoft.com/en-us/azure/azure-signalr/signalr-quickstart-dotnet-core#create-an-azure-signalr-resource) | ||
| - Make sure the connectionstring is setup under the following key: `Azure:SignalR:ConnectionString` | ||
| - Add a reference to the Microsoft.Azure.SignalR NuGet package | ||
| - Add the following composer to your project | ||
eshanrnh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```csharp | ||
| using Umbraco.Cms.Core.Composing; | ||
|
|
||
| namespace Umbraco.Cms.Web.UI.SignalRLoadBalancing; | ||
|
|
||
| public class SignalRComposer : IComposer | ||
| { | ||
| public void Compose(IUmbracoBuilder builder) => builder.Services.AddSignalR().AddAzureSignalR(); | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
17/umbraco-cms/reference/configuration/distributedjobssettings.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Distributed jobs settings | ||
|
|
||
| The distributed jobs settings allow you to configure how Umbraco handles distributed background jobs in a load-balanced environment. | ||
|
|
||
| ## Configuration | ||
| ```json | ||
| "Umbraco": { | ||
| "CMS": { | ||
| "DistributedJobs": { | ||
| "Period": "00:00:05", | ||
| "Delay": "00:01:00" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Settings | ||
|
|
||
| ### Period | ||
|
|
||
| **Default:** `00:00:05` (5 seconds) | ||
|
|
||
| Specifies how frequently each server checks for distributed background jobs that need to be run. | ||
|
|
||
| A shorter period means jobs are picked up more quickly, but increases the frequency of database queries. A longer period reduces overhead but may introduce delays in job execution. | ||
|
|
||
| ### Delay | ||
|
|
||
| **Default:** `00:01:00` (1 minute) | ||
|
|
||
| Specifies how long the server should wait after initial startup before beginning to check for and run distributed background jobs. This startup delay ensures that the application is fully initialized and stable before participating in distributed job processing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.