Search

 

User:Developer

Prerequisites

- not applicable

Introduction

Using IIS Application Request Routing to load balance Futurama applications

 

Description

Application Request Routing (ARR) is a feature in the IIS (Internet Information Services) Manager that can be used for load balancing of server requests and increase scalability of web applications. ARR can also be applied on web applications made with Futurama. At this page you will find information about how to configure ARR so it can be used to loadbalance Futurama applications. At this page an environment is created using two Futurama instances where the load is balanced. This can be extended to more instances if desirable. In the example a Futurama Webservice application is used. For Futurama Website applications the same configuration can be used.

Installation

In IIS the feature ARR has to be installed first. You can do this with the Web Platform Installer (WebPI) in IIS. If WebPI is not yet installed in IIS, you can install it by clicking "Get New Web Platform Components" in the Actions panel of the server (parent) node. In WebPI search and install the latest version of ARR and close and open IIS again after the installation. If ARR is installed well, you will see a new node in the "Connections" panel at the left named Server Farms.

Configuration

ARR can be used to load balance a Futurama application (either website or webservice). For an example of a webservice application and help about webservices, see the page Webservice Installation.

In IIS add 2 new "Websites" in two different Application Pools that listen on a port that is not yet used, for example 9001 and 9002. As "Physical path" give the location of the folder that contains the Futurama webservice code. Now you have two Websites referring to the webservice, one listening on port 9001 and the other on port 9002. In the picture below you can see the configuration of adding one of the "websites". The type binding is either http or https, depending on your situation. Be sure not to use a host name for the binding, only a port number. Using a host name this will lead to “Bad request” errors.

image

 

Create a new website to respond to the requests that will be managed by the ARR

Next create a new Website in IIS (for example Futurama_Farm).:

  • Choose a free port for this Website, for example port 9000
  • As physical path choose an existing location (for example C:\inetpub\wwwroot). This location has to exist, but will not used.

This binding will be used to make requests to the ARR. With this configuration the site listens to the url http://localhost:9000.

Server Farm

Create server farm

Next step is to create a new Server Farm in the node "Server Farms". Specify a name for the Server Farm, for example "ARR". Click next and add servers to the server farm. In this example localhost is used for the servers. Type localhost1 as Server address, click Advanced settings... and give 9001 as httpPort. Add a second server named localhost2 with httpPort 9002, see picture below. For the server addresses localhost1 and localhost2 to work, they have to be defined in DNS, and are different host names for 127.0.0.1. When you are prompted whether you want that IIS will make an URL Rewrite Rule, choose No. The URL Rewrite Rule is defined in the next step.

image

View settings servers server farm

After adding a server to the server farm in IIS it is not possible to view the settings of the server. If necessary it is possible to see these settings by checking the content of the applicationHost.config. This file can be found at the server in the folder C:\Windows\System32\inetsrv\config.

URL Rewrite

To be able to make requests to the ARR, an URL Rewrite Rule has to be made so that incoming request on a specified URL will be routed to the server farm. The URL Rewrite Rule has to be added at the server level/parent node. Choose the feature URL Rewrite, click Add Rule(s)..., choose Blank rule under Inbound rules.

Give the inbound rule a name of choice, for instance ARRServerFarmRule. Under Match URL in Pattern enter the text ".*". This means that the rule will match with any incoming URL.

image

Under Conditions add a new condition. In Condition input enter the text "{HTTP_HOST}" and in Pattern enter the text ".*". This condition matches with any available host name. Add a second condition with the text {SERVER_PORT} in Condition input and the text "9000" in Pattern. This rule will only match with incoming requests on port 9000.

image

Under Action, choose the Action type "Route to Server Farm" and choose the Server farm "ARR" that we made. With this rule we route incoming requests that matched the conditions to the server farm. The Path contains {R:0} and stands for the back reference, see this page for more information about back references. Enable the box "Stop processing of subsequent rules" so that other rules in URL Rewrite module will not be executed.

image

Click Apply in the Actions panel, the Application Request Routing and URL Rewriting are now set.

 

Session Affinity

Note: if you use ARR for traffic meant for Futurama Web (creating websites), you will need Session Affinity, This will make sure that every request for a session will be managed by the same instance. Server Affinity can be selected in IIS by clicking on the FuturamaFarm. In the Server Farm pane Server Affiny can be selected. Select Client Affinity and choose a Cookie Name (for example ARRSessionCookie). Make sure a cookie name is selected that is not used as a session or authentication cookie in your website application.

Load Balance

In the Server Farm there are several features, one of them is the Load Balance feature. In this feature you can set how the incoming requests will be routed to the underlaying servers. For the Load balance algorithm choose "Weighted round robin" and for Load distribution choose "Even distribution". The request will now be evenly distributed over the servers.

Health Test

The Health Test in ARR is a very helpful feature and can be used to check whether a server is healthy or not. This is needed in case one of the servers in the server farm goes down. When a server is down, ARR marks that server as unhealthy and doesn't send request to that server anymore. Click the Health Test feature and set properties for URL Test. In URL fill in the URL that we use to reach the ARR "http://localhost:9000". Enter the value "1" in Interval and Time-out. The Acceptable status codes can stay "200-399" and in Respone match enter the text "Service".

Monitoring and Management

In the ARR feature Monitoring and Management you can see the statistics of the servers, like health status, total requests, failed requests and more.

Troubleshooting

With the feature Failed Request Tracing (FRT) you can troubleshoot problems caused by ARR. The feature FRT has to be installed on your machine. Do this by enabling Tracing in "Windows Features" (Internet Information Services -> World Wide Web Services -> Health and Diagnostics -> Tracing).

Installation

Next step is to enable FRT in IIS. Below the steps to enable FRT:

  1. Choose the website in IIS that contains the URL to ARR;
  2. In the Actions panel of this IIS website under Configure open Failed Request Tracing and enable it;
  3. Open in the IIS website  the feature Failed Request Tracing Rules and click Add... in the Actions panel;
  4. Choose "All content (*)" en click Next;
  5. In Status code(s) enter "100-999", this means that requests with all status codes will be traced;
  6. Click Next and enable the properties "RequestRouting" and "Rewrite" under WWW Server, the other properties can be disabled. When you don't see the properties RequestRouting and Rewrite, you have to repair the modules "Microsoft Application Request Routing 3.0" and "IIS URL Rewrite Module 2" in "Programs and Features".

image

Analyzing

After enabling FRT the failed logs will be stored in the %SystemDrive%\inetpub\logs\FailedReqLogFiles folder. Open the .xml in Internet Explorer to see the log information. If the information is not displayed, adjust the security settings at the server, or copy the files to an environment where these files can be viewed.

Feedback

If you have any questions about this subject or if you want to provide us feedback please send us an e-mail.

Updated: 2016-09-15