Examine in load balanced environment 'umbracoServer' database table
s
Hi, We've an Umbraco 10.8.2 site in a load balanced environment. Following the documentation we need to set the right *serverrole * to the backoffice and frontend server by implementing a **custom ServerRegistrarComposer**: https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/fundamentals/setup/server-setup/load-balancing/flexible-advanced *Question: * When we do this the database table umbracoServer won't be filled, is that correct? Or should this table always be filled?
m
Yep nothing gets logged to the table as you've explicitly set away from the electedServerRole... https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs#L67-L73
s
Hi @Mike Chambers But what is the best practise in this case? Should we set the electedServerRole? And if so, how should we do that exaclty? We still get problems after a deploy to these 2 servers. The index of one of these servers is empty or not fully reindexed. It changes from server to server, so one time it's the backend server and the other time it is the frontend server. Thanks in advance!
m
Nope, you should explicitly set the roles when loadbalancing, and the table will cease to receive data. (To stop it doing what I think you are seeing where servers are getting elected based on which one is live fiest) You can check for the correct role in views with
Copy code
csharp
@inject IServerRoleAccessor serverRoleAccessor;    @(serverRoleAccessor.CurrentServerRole)
Did you also notice that the examine settings should be different between
schedulingpublisher
and
subscriber
? https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/fundamentals/setup/server-setup/load-balancing/azure-web-apps#lucene-examine-configuration I think you would take the same approach for any flexible setup as azure.
If it's slot swapping in azure I think there was also something about overlapped recycling where you could have your schedulingpublihser with 2 live env during the swap (to mitigate the downtime) however you can add
WEBSITE_DISABLE_OVERLAPPED_RECYCLING ->  NO
to the configuration appsettings in azure to stop this.
s
Hi @Mike Chambers We have added logs to check the role of the server and that seems correct for both servers.
About the examine settings we have the following setup: Backoffice: LocalTempStorageLocation: EnvironmentTemp LuceneDirectoryFactory: SyncedTempFileSystemDirectoryFactory IsSchedulingPublisherServer: True MainDomLock: FileSystemMainDomLock Frontdoor: LocalTempStorageLocation: EnvironmentTemp LuceneDirectoryFactory: TempFileSystemDirectoryFactory IsSchedulingPublisherServer: False MainDomLock: FileSystemMainDomLock
m
Sorry 1.. if you don't want overlappng.. 😉 https://learn.microsoft.com/en-us/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet#scaling When are logging for
IsSchedulingPublisherServer: False
are you actually checking that your subscribers are Role == Subscriber and not just
!schedulingPublisher
? (sorry if that's asking you to suck eggs) We have
Copy code
csharp
using Umbraco.Cms.Core.Sync;

namespace www.Extensions.LoadBalancing
{
    public class SetServerRegistrarRoles : IServerRoleAccessor
    {
        private readonly IWebHostEnvironment _env;

        public SetServerRegistrarRoles(IWebHostEnvironment env)
        {
            _env = env;
        }

        public ServerRole CurrentServerRole
        {
            get
            {
                return _env.EnvironmentName switch
                {
                    "Development" => ServerRole.Single,
                    "Production" or "Staging" or "Local.Publisher" => ServerRole.SchedulingPublisher,
                    _ => ServerRole.Subscriber,
                };
            }
        }
    }
}
Note the default of
ServerRole.Subscriber
as from memory there was something where the Environment name was returning null or empty in some scenario....
Just had a memory of this setting too.. https://docs.umbraco.com/umbraco-cms/v/10.latest-lts/reference/configuration/globalsettings#disable-election-for-single-server might be of use to stop any election.. though not sure unde the hood what it is actually doing... EDIT: Actually no.. not of use
Copy code
csharp
// register a server registrar, by default it's the db registrar
            Services.AddUnique<IServerRoleAccessor>(f =>
            {
                GlobalSettings globalSettings = f.GetRequiredService<IOptions<GlobalSettings>>().Value;
                var singleServer = globalSettings.DisableElectionForSingleServer;
                return singleServer
                    ? new SingleServerRoleAccessor()
                    : new ElectedServerRoleAccessor(f.GetRequiredService<IServerRegistrationService>());
            });
https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs#L248C13-L256C16
82 Views