iisweb-farm

Configure IIS Web Farm to prefer specific server


I've setup a Web Farm in IIS 8 (Windows 2012) with ARR 3.0. The Farm has two servers. Is it possible to configure all requests to be directed to a specific server (if healthy) and only if this server is not healthy, the requests to be directed to the second server?


Solution

  • I haven't found a solution but I implemented a workaround that solves my problem. I used the Health Test feature of the Server Farm. On the preferred server the health test url responds OK. On the secondary server the health test url checks if the preferred server is functional and responds with a HTTP status code outside the acceptable status codes if it is, or OK if it isn't.

    Implementation with ASP

    The Health Test URL is http://serverFarm/HealthTest.asp where 'serverFarm' is the Server Farm name given when the farm was created.

    Preferred Server's HealtTest.asp

    <%@ LANGUAGE=JScript CODEPAGE=65001%>
    
    <%
        Response.Write('OK');
    %>
    

    Secondary Server's HealthTest.asp

    <%
        var XMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP");
        var ReqURL = 'http://preferred.server.ip/HealthTest.asp';
    
        try {
            XMLHTTP.open("GET" , ReqURL, false);
            XMLHTTP.send("");
    
            if(200 == XMLHTTP.status)
            {
              Response.Status = "403 Primary server Active";
            }
            else
              Response.Write('OK');
        } catch (e) {
          Response.Write('OK');
        }
    %>