Copied to clipboard

Flag this post as spam?

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


  • Peter Laurie 42 posts 116 karma points
    Nov 05, 2019 @ 10:03
    Peter Laurie
    0

    Load Balancing - update instructions not carried to front end servers

    Hi, We are trying to set up a load balancing system in line with your Umbraco documentation. The set up we have right now has two front end servers, serving content to the outside world, through the load balancer. Much like your diagram on page (https://our.umbraco.com/documentation/getting-started/setup/server-setup/load-balancing/). These two servers are within our internal DMZ. The server we access the umbraco CMS on, at the moment is NOT within the internal DMZ, hence, while our front end servers are on a 192.168.1.* network, our back end server is on 10.2.1.* network, but we access the CMS on our internal network. Looking at the umbracoServer section of the Umbraco database it seems that no servers are registered, master or slave, although we have implemented the flexible load balancing set up on this page (https://our.umbraco.com/documentation/getting-started/setup/server-setup/load-balancing/flexible-advanced).

    We have a setting in the web.config that determines the website or sub domain, and also, the dns hostname of the server is used to determine if the Umbraco installation is Master or slave:

    // START: FLEXIBLE SERVER LOAD BALANCING     
      string hostName = Dns.GetHostName();
      //This should be executed on your slave servers .int.ncit.co.uk
      if (hostName == "nbbe-web-01" || hostName == "nbbe-web-02")
      {
        composition.SetServerRegistrar(new FrontEndReadOnlyServerRegistrar());
        SendEmail("Start up from", hostName);
      }
      //This should be executed on your master server
      else if (hostName == "nbbe-cmteweb-01")
      {
        composition.SetServerRegistrar(new MasterServerRegistrar());
        SendEmail("Start up from", hostName);
      }
    

    The Send email part id just a temporary tests email to tell us what is going on at startup.

    The slave server c# code is as the documentation instructs:

    public class FrontEndReadOnlyServerRegistrar : IServerRegistrar
    {
    
    public IEnumerable<IServerAddress> Registrations
    {
      get { return Enumerable.Empty<IServerAddress>(); }
    }
    public ServerRole GetCurrentServerRole()
    {
      return ServerRole.Replica;
    }
    public string GetCurrentServerUmbracoApplicationUrl()
    {
      return null;
    }
    }
    

    The master server code is as follows, depending on the umbracoStartup value in the web config, one of the umbraco cms url's is used:

    public class MasterServerRegistrar : IServerRegistrar
    {
    
    readonly private string UmbracoStartup = AppSettings.Get<string>("UmbracoStartup"); // make sure UmbracoStartup in web.config is set to either "www" or "news" (or "test" for testing)
    readonly string currentServer = "https://www.ourwebsite.co.uk/umbraco";
    readonly string currentServerNews = "https://news.ourwebsite.co.uk/umbraco";
    readonly string currentServerUmb = "https://test.ourwebsite.co.uk/umbraco";
    
    public IEnumerable<IServerAddress> Registrations
    {
      get { return Enumerable.Empty<IServerAddress>(); }
    }
    public ServerRole GetCurrentServerRole()
    {
      return ServerRole.Master;
    }
    public string GetCurrentServerUmbracoApplicationUrl()
    {
    
      // NOTE: If you want to explicitly define the URL that your application is running on,
      // this will be used for the server to communicate with itself, you can return the
      // custom path here and it needs to be in this format:
      // http://www.mysite.com/umbraco
    
      if (UmbracoStartup.Contains("news"))
        return currentServerNews;
      else if (UmbracoStartup.Contains("test"))
        return currentServerUmb;
      else
        return currentServer;
    }
    }
    

    As I previously mentioned, our master and slave servers are NOT registering in the umbracoServer table of the CMS. We are going to try moving the backend (master) installatyion into the DMZ so it is on the same 192.168.1.* network as the front end servers. Hopefully this will enable all severs to register if they are slave or master servers.

    I have a question to get this started:

    1. Does anyone with an in-depth knowledge of setting Umbraco up for load balancing have their thoughts on the above set up. At the moment changes in the CMS are not copied over to the front end slaves, it seems like a restart forces any changes over, eventually, this is very frustrating, to the point our content editors end up not very happy indeed when they make a change and expect it to be seen on the outside world within minutes.

      We use Task scheduler to copy over changes to the front end servers from the back end server (like image updates and cshtml and bin changes). Folders such as AppData/Temp and AppData/Logs are not replicated over.

    Any experience and feedback would be most welcome.

    Thank you.

    Kind regards, Pete

  • Steve Megson 151 posts 1022 karma points MVP c-trib
    Nov 05, 2019 @ 10:53
    Steve Megson
    2

    The umbracoServer table is used by the default DatabaseServerRegistrar to select a master, so it won't be used if you're explicitly setting each server to be Master or Replica. There should, however, be rows in umbracoCacheInstruction. The other place to check is the App_Data\TEMP\DistCache folder, which should contain the last instruction ID that each server processed.

  • Peter Laurie 42 posts 116 karma points
    Nov 05, 2019 @ 12:05
    Peter Laurie
    0

    Hi Steve, Thank you for that reply, that clarifies a few things a bit more.

  • Peter Laurie 42 posts 116 karma points
    Nov 05, 2019 @ 12:49
    Peter Laurie
    0

    Hi Steve, The DistCache folder, does that contain one entry - for that particular server - or three entries, in this case, as we have one master and two Replica servers, each with an id showing what instruction was processed and when?

  • Steve Megson 151 posts 1022 karma points MVP c-trib
    Nov 05, 2019 @ 13:31
    Steve Megson
    0

    Each server should have one file in that folder, containing the last ID for that server.

  • Peter Laurie 42 posts 116 karma points
    Nov 05, 2019 @ 17:26
    Peter Laurie
    0

    Hi Steve, Thanks again for all your feedback. From what you told me, backed up by a few tests, then it seems our set up fine and content updates are being reflected on our front end servers.

    We will turn our attention now to caching, and what we can do so that a small content change on a page is seen within minutes or so when I look at it remotely on my mobile for example, or desktop. Right now that is not happening. Looking into if MvcDonutCaching will work on the new caching system in Umbraco 8.

    Kind regards,

    Pete

  • Bradley Kronson 62 posts 113 karma points
    May 21, 2021 @ 13:34
    Bradley Kronson
    0

    I'm explicitly setting each server to be Master or Replica

    But not seeing a DistCache folder in the App_data/Temp

    Any ideas?

  • Gabor Ferencz 36 posts 167 karma points
    May 26, 2022 @ 14:00
    Gabor Ferencz
    0

    Hi, same here, no distcache on the server? Any ideas?

Please Sign in or register to post replies

Write your reply to:

Draft