Overview
This topic leads the reader through the steps to configure a 3-tier deployment architecture using Application Request Routing. The 3-tier deployment architecture consists of a web tier, an application server tier and a data tier as shown below:

Typically in this deployment scenario, the static contents are served by the tier 1 servers while the dynamic contents are served by the business logic in tier 2 servers.
Goal
To configure 3-tier deployment architecture using Application Request Routing. In this walkthrough, the Application Request Routing would serve as the first tier server and the data store is a file system that resides on the content server as shown below:

Application Request Routing will serve as a router, a load balancer and a content server that serves static contents.
Prerequisites
This walkthrough requires the following prerequisites:
- IIS 7.0 on Windows 2008 (any SKU).
- Microsoft URL Rewriter Customer Technical Preview (CTP) 1.
- Microsoft Application Request Routing CTP1.
- Minimum 2 content servers with ASP.NET installed.
If URL Rewriter CTP1 or Application Request Routing CTP1 has not been installed, it is available for download at:
- URL Rewriter x86
- URL Rewriter x64
- Application Request Routing x86
- Application Request Routing x64
Another prerequisite is that the reader has defined and configured a server group using the steps outlined in Define and Configure an Application Request Routing (ARR) Server Group. The server should look like the diagram below, before proceeding:

Step 1 – Make the static contents available for Application Request Routing
The sample site, Comic.NET, as created in Define and Configure an Application Request Routing (ARR) Server Group, stores all the images in following folders:
- /Images/
- /Admin/Images/
- /Themes/ComicNet/Images/
- /Repository/Comics/
The steps outlined below effectively share the static contents to the server where Application Request Routing is installed:
1. In an elevated command prompt (Click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator), navigate to the root of the Default Web Site.
2. Create a symbolic link for the \Images\ folder:
mklink /d <Link> <Target>
(ie: mklink /d Images c:\inetpub\ComicSite1\Images)
3. From the root of the Default Web Site, create an \Admin\ directory and change directory to \Admin\:
mkdir Admin
cd Admin
4. Create a symbolic link for the \Admin\Images\ folder:
mklink /d <Link> <Target>
(ie: mklink /d Images c:\inetpub\ComicSite1\Admin\Images)
5. From the root of the Default Web Site, create a \Themes\comicNet\ directory and change directory to \Themes\ComicNet\:
mkdir Themes
mkdir comicNet
6. Create a symbolic link for the \Themes\comicNet\Images\ folder:
mklink /d <Link> <Target>
(ie: mklink /d Images c:\inetpub\ComicSite1\Themes\comicNet\Images)
7. Create a symbolic link for the \Repository\ folder
mklink /d <Link> <Target>
(ie: mklink /d Repository c:\inetpub\ComicSite1\Repository)
Step 2 – Create URL rewrite rules
If there are any previous rewrite rules in URL Rewrite Module, remove them by selecting the rules and under Actions, click on Remove.
In this step, URL Rewrite rules are created so that the images in the \Images\, \Admin\Images\, and \Themes\comicNet\Images\ as well as JPG files in \Repository\ subfolders are are served directly by Application Request Routing while the rest of the requests are routed to the content servers, which would be responsible for serving the dynamic contents.
To create URL rewrite rules via UI:
1. Launch IIS 7 inetmgr.
2. Select the root of the server:

Locate URL Rewrite Module icon under IIS group heading and double click on the icon.
3. To create an URL Rewrite Rule, under Actions, click on Add Rule… and enter the following values:
- Name: Do not route files in Images folders
- Requested URL: Matches the pattern
- Using: WildCards
- Pattern: *Images/*
- Ignore Case: Checked

The rule checks to see if the requested URL contains *Image/*.
4. Since the Application Request Routing and the two sample sites, comicSite1 and comicSite2, are installed and created on the same server, we will have to add a condition so that the URL rewrite rule is only applied on the initial requests on port 80. Click on Add Conditions and click on Add…. Enter the following values:
- Condition input: {SERVER_PORT}
- Check if input string: Matches the pattern
- Pattern: 80
- Ignore case: Checked

5. Under Action, enter the following values:
- Action Type: None
- Stop processing of subsequent rules: Checked

None selection combined with Stop processing of subsequent rules indicate that the requests matching this rule should not be routed to other servers. Instead, they should be served by Application Request Routing.
Under Actions, click on Apply. After saving, click on Back to Rules to create more rules.
6. Another rule is needed to manage the JPG files in \Repository\Comics\. We could create a rule to match the path, as we have done with *Images/* but, instead, we will match the file extension, .JPG in this example. Under Actions, click on Add Rule… and enter the following values:
- Name: Do not route .JPG files
- Requested URL: Matches the pattern
- Using: WildCards
- Pattern: *.JPG
- Ignore Case: Checked

The rule checks to see if the requested URL contains *.JPG.
7. Since the Application Request Routing and the two sample sites, comicSite1 and comicSite2, are installed and created on the same server, we will have to add a condition so that the URL rewrite rule is only applied on the initial requests on port 80. Click on Add Conditions and click on Add…. Enter the following values:
- Condition input: {SERVER_PORT}
- Check if input string: Matches the pattern
- Pattern: 80
- Ignore case: Checked

8. Under Action, enter the following values:
- Action Type: None
- Stop processing of subsequent rules: Checked

None selection combined with Stop processing of subsequent rules indicate that the requests matching this rule should not be routed to other servers. Instead, they should be served by Application Request Routing.
Under Actions, click on Apply. After saving, click on Back to Rules to create more rules.
9. The last rule is to indicate that the remaining requests should be routed to the comicSiteServers server group. Under Actions, click on Add Rule… and enter the following values:
- Name: Route the rest to comicSite servers
- Requested URL: Matches the pattern
- Using: WildCards
- Pattern: *
- Ignore Case: Checked

The wildcard value for the URL matches all remaining requests.
10. Since the Application Request Routing and the two sample sites, comicSite1 and comicSite2, are installed and created on the same server, we will have to add a condition so that the URL rewrite rule is only applied on the initial requests on port 80. Click on Add Conditions and click on Add…. Enter the following values:
- Condition input: {SERVER_PORT}
- Check if input string: Matches the pattern
- Pattern: 80
- Ignore case: Checked

11. Under Action, enter the following values:
- Action Type: Rewrite
- Rewrite URL: http://comicSiteServers/{R:1}
- Append query string: Checked

Note that the server group alias, comicSiteServers, is referenced in the Rewrite URL, to indicate that the requests will be routed to the servers in comicSiteServers server group.
Under Actions, click on Apply.
12. Send several requests to the default site on port 80.
13. To verify that the static images are being served from Application Request Routing, inspect the logs for both comicSite1 and comicSite2. The logs are by default under c:\inetpub\logs\LogFiles\:
- comicSite1: W3SVC2
- comicSite2: W3SVC3
Verify that the logs do not contain any references to /Images/ or *.jpg. You may want to send additional requests and inspect the logs, as needed
14. To verify that the dynamic contents are being load balanced between comicSite1 on port 9000 and comicSite2 on port 9001, refresh the dashboard in IIS 7 inetmgr. Note that the runtime statistics are changing for both sites. You may want to send additional requests and refresh the dashboard, as needed.

Summary
You have now successfully defined the rules in URL Rewriter and properties in Application Request Routing to enable a 3-tier deployment architecture scenario. For additional Application Request Routing properties and capabilities, refer to HTTP Load Balancing using Application Request Routing (ARR) walkthrough.
Related Content
Comments