Internet Information Services 7.x

Internet Information Services (IIS) 7.x provides load balancing tools through IIS extensions.

The IIS extensions are:

Both tools are required to do the job.

The following examples show the resulting configuration entries. It can be done either by editing the configuration files manually or by using the IIS manager user interface. For more information on how to use the IIS manager user interface, see HTTP Load Balancing using Application Request Routing.

Sessionless requests

The following example shows how to configure IIS 7.x to do load balancing for sessionless requests. It assumes the architecture illustrated by the sample architecture 1.
<configuration>
  ...
  <system.webServer>
    ...
    <rewrite>
      <globalRules>
        ...
        <rule name="ARR_GASFarm_loadbalance" enabled="true" 
        patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions />
          <action type="Rewrite" url="http://GASFarm/{R:0}" />
        </rule>
      </globalRules>
    </rewrite>

    <proxy enabled="true" />

  </system.webServer>
  ...
  <webFarms>
    ...
    <webFarm name="GASFarm" enabled="true">
      <server address="GAS1.corporate.com" enabled="true">
        <applicationRequestRouting weight="100" />
      </server>
      <server address="GAS2.corporate.com" enabled="true">
        <applicationRequestRouting weight="100" />
      </server>
      <applicationRequestRouting>
        <loadBalancing algorithm="WeightedRoundRobin" />
        <affinity useCookie="false" />
      </applicationRequestRouting>
    </webFarm>
  </webFarms>
  ...
</configuration>
  • These configuration entries can be put at the server level in the applicationHost.config file.
  • In the globalRules section of the rewrite section, the rule named ARR_GASFarm_loadbalance tells the module to rewrite all incoming requests so that they are routed to the GASFarm web farm.
  • The proxy is enabled in order to forward the requests to the two GAS servers.
  • The web farm named GASFarm is declared with the two GAS servers.

For example, the http://localhost/ws/r/echo URL will be rewritten to http://GAS1.corporate.com/ws/r/echo, assuming that the GAS1.corporate.com server has been chosen.

Session-bound requests

The following example shows how to configure IIS 7.x to do load balancing for session-bound requests. It assumes the architecture illustrated by the sample architecture 1. The example illustrates cookie-based request routing.
<configuration>
  ...
  <system.webServer>
    ...
    <rewrite>
      <globalRules>
        ...
        <rule name="ARR_GASFarm_loadbalance" enabled="true" 
        patternSyntax="Wildcard" stopProcessing="true">
          <match url="*" />
          <conditions />
          <action type="Rewrite" url="http://GASFarm/{R:0}" />
        </rule>
      </globalRules>
    </rewrite>

    <proxy enabled="true" />

  </system.webServer>
  ...
  <webFarms>
    ...
    <webFarm name="GASFarm" enabled="true">
      <server address="GAS1.corporate.com" enabled="true">
        <applicationRequestRouting weight="100" />
      </server>
      <server address="GAS2.corporate.com" enabled="true">
        <applicationRequestRouting weight="100" />
      </server>
      <applicationRequestRouting>
        <loadBalancing algorithm="WeightedRoundRobin" />
        <affinity useCookie="true" />
      </applicationRequestRouting>
    </webFarm>
  </webFarms>
  ...
</configuration>  
  • These configuration entries can be put at the server level in the applicationHost.config file.
  • In the globalRules section of the rewrite section, the rule named ARR_GASFarm_loadbalance tells the module to rewrite all incoming requests so that they are routed to the GASFarm web farm.
  • The proxy is enabled in order to forward the requests to the two GAS servers.
  • The web farm named GASFarm is declared with the two GAS servers.
  • The useCookie attribute of the affinity element is set to true; actually, this is the only difference compared to the sessionless request routing.

For example, the http://localhost/ua/r/gwc-demo URL will be rewritten to http://GAS1.corporate.com/ua/r/gwc-demo, assuming that the GAS1.corporate.com server has been chosen.