Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Efe 12 posts 43 karma points
    Mar 22, 2022 @ 18:51
    Efe
    1

    Umbraco 9 Load balancing config

    Hello,

    I've successfully set up load balancing for v7 & v8 websites following the guidelines here https://our.umbraco.com/Documentation/Fundamentals/Setup/server-setup/load-balancing/flexible-advanced#explicit-schedulingpublisher-server

    I'm trying the same for v9. I've created 2 classes implementing IServerRoleAccessor for each server role. I can't get the next part working.

    "then you'll need to replace the default IServerRoleAccessor for the your custom registrars. You'll can do this by using the SetServerRegistrar() extension method on IUmbracoBuilder from a Composer or directly in your startup.cs."

    I'm unable to find the extension method SetServerRegistrar on IUmbracoBuilder in a Composer or from startup.cs.

    Do I need to create the extension method myself? If not can someone point me in the direction of the necessary namespace?

    Has anyone got this working? If so, some example code would be appreciated.

    thanks in advance Efe

  • OzoneNZ 1 post 91 karma points
    Mar 23, 2022 @ 10:34
    OzoneNZ
    100

    Try adding this to your C# file:

    using Umbraco.Cms.Infrastructure.DependencyInjection;

  • Sander van de Pas 74 posts 147 karma points
    Mar 23, 2022 @ 11:19
    Sander van de Pas
    3

    Hi,

    You could set these values in a custom Composer like below. For each server set the right value in the appsettings.json file.

    using System.Linq;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Umbraco.Cms.Core.Composing;
    using Umbraco.Cms.Core.DependencyInjection;
    using Umbraco.Cms.Infrastructure.DependencyInjection;
    using Umbraco.Extensions.Infrastructure.ServerRoleAccessors;
    
    namespace Umbraco.Extensions.Composers
    {
        public class ServerRegistrarComposer : IComposer
        {
            public void Compose(IUmbracoBuilder builder)
            {
                var config = builder.Services.BuildServiceProvider().GetService<IConfiguration>();
    
                if (config.GetChildren().Any(item => item.Key.InvariantEquals("custom")))
                {
                    if (config.GetValue<bool>("Custom:IsSchedulingPublisherServer"))
                    {
                        // This should be executed on your single `SchedulingPublisher` server
                        builder.SetServerRegistrar<SchedulingPublisherServerRoleAccessor>();
                    }
                    else
                    {
                        // This should be executed on your `Subscriber` servers
                        builder.SetServerRegistrar<SubscriberServerRoleAccessor>();
                    }
                }
            }
        }
    }
    
  • Efe 12 posts 43 karma points
    Mar 23, 2022 @ 16:49
    Efe
    0

    OzoneNZ, Sander,

    Thanks to both of you. You've been a massive help and between you have helped resolve the problem I was having.

    thanks Efe

Please Sign in or register to post replies

Write your reply to:

Draft