You've just downloaded and installed Traffic Manager, and you're wondering "where next?". This article talks through the process of load-balancing traffic to a public website, and explains the potential pitfalls and how to overcome them.
We'll look at how to set up a basic load balanced service using the Manage a New Service wizard, then consider four potential problems:
Problem
Solution
When you access the Web site through Traffic Manager, it responds with a 404 Not Found or other error, or redirects you directly to the website
You need to correct the Host Header in the request your web browser has sent. Use a simple Request Rule in Traffic Manager to patch the request up correctly.
The web site stops working when you access it through Traffic Manager
Traffic Manager is running Ping health checks against the web servers, and these are failing because the public servers won't respond to pings. Remove the health checks, or replace them with HTTP checks.
Links in the web content refer directly to the fully-qualified domain of the website, rather than to the website delivered through Traffic Manager
You need to rewrite the web content to correct the fully-qualified links. Use a response rule in Traffic Manager to make this change.
HTTP Location redirects and cookies issued by the website refer to the fully-qualified domain of the website, rather than to the website delivered through Traffic Manager
You need to use the connection management settings to transparently rewrite the Location and Set-Cookie headers as appropriate
Basic Load Balancing
Let's start with a simple example. Select a target website, such as www.w3.org. Fire up the Manage a New Service wizard:
This will pop up a new window to step you through the process of creating a new service.
Warning: If you don't see the pop-up window, your web browser may be configured to prevent popups. Check and fix this problem.
Step through the wizard. Create a service named web site, listening on port 80:
Specify the servers ("nodes") that will host the website. In this example, enter www.w3.org, port 80:
Note: If you get an "ERROR: Cannot resolve" message, then most likely your Traffic Manager is not configured with a correct nameserver address, or it cannot route to the outside world. You'll need to fix these problems before continuing:
You can use 8.8.8.8 as the nameserver
Ensure that the networking is configured so that the Traffic Manager has external connectivity
Review your settings and commit the result:
Note: If you get a 'Cannot Bind' error when you commit the changes, then another service on the Traffic Manager is listening on port 80.
If it's a pre-existing Traffic Manager Virtual Server, you should stop this virtual server
It it's another service on the same host (for example, a webserver), you should stop this service
Alternatively, select another port (instead of port 80).
The wizard will create a virtual server object listening on port 80, and a pool object containing the www.w3.org nodes (or whatever you chose). The Virtual Server will receive traffic and then pass it on to the pool for load balancing.
Try it out
Try it out. Go to http://your-traffic-manager-ip-address/ with your web browser. If you are lucky, it will work first time, but most likely, you'll get an error message, or possibly a redirect to http://www.yourwebsite.com/.
Problem #1: The Host Header
Most webservers host many websites on the same IP address and port. They determine which website a particular request is destined for by inspecting a parameter in the request called the 'Host Header'.
The 'Host Header' is constructed from the URL that you typed in your web browser (for example: http://192.168.35.10/). This will cause the webbrowser to include the following header in the request:
Host: 192.168.35.10
The web server will reject this request, returning either an error message, 404 Not Found, or a forceful redirect to the correct page. You can use a TrafficScript Rule to change the host header in the request to a value that the web site will recognise.
How to create the TrafficScript Rule
Edit the 'web site' virtual server you created and navigate to the 'Rules' page. In the 'Request Rules' section, click the 'Manage Rules in Catalog' link to create a new rule that is associated with that virtual server:
Create a TrafficScript rule called 'w3.org host header':
with the following text http.setHeader( "Host", "www.w3.org" );
and save your changes. Now, Traffic Manager will fix up the host header in every request and the site should render correctly.
Problem #2: Health Monitors
If your Traffic Manager service works for a short time, then starts returning a "Service Unavailable" error message, you've most likely hit a health monitoring problem.
When Traffic Manager creates a new pool, it assigns a 'ping' health monitor to the nodes. Many public webservers, and websites that are delivered over a CDN, do not respond to 'ping' healthchecks, so this monitor will quickly fail and mark the nodes as unavailable.
Edit the 'web site pool' Pool object and locate the Health Monitoring section. Remove the Ping health monitor:
This will clear the error. You could replace the Ping health check with an HTTP health check (for example) if you wished.
Problem #3: Embedded Links
As you click round the website that is delivered through Traffic Manager, you may find that you jump off the http://your-traffic-manager-IP-address/ version of the site and start going directly to the http://www.site.com/ URLs.
This may happen because the website content contains absolute, fully-qualified links:
<a href="http://www.nytimes.com/headlines">Headlines</a>
rather than unqualified links:
<a href="https://community.brocade.com/headlines">Headlines</a>
Yes, this is a problem if you load-balance to www.nytimes.com for example. You can fix those links up by rewriting the HTML responses from the webservers using a Response Rule in Traffic Manager:
$contentType = http.getResponseHeader( "Content-Type" ); if( string.startsWith( $contentType, "text/html" ) ) { $body = http.getResponseBody(); $body = string.replaceAll( $body, "http://www.nytimes.com/", "/" ); http.setResponseBody( $body ); }
Problem #4: Cookies and Location redirects
The origin webserver may issue cookies and Location redirects that reference the fully-qualified domain of the website, rather than the IP address of the Traffic Manager device. Your web browser will not submit those cookies, and it will jump to the origin website if it follows a Location redirect.
Traffic Manager can automatically patch up these parts of the HTTP response, using the Cookie and Location Header settings in the Connection Management page of your Virtual Server's configuration:
Rewrite domains, paths and other cookie parameters when proxying a website using a different URL
Intelligently rewrite location redirects so that users are not hopped on to the origin server
Use these settings to address any inconsistencies and problems related to cookies or location redirects.
Conclusion
These three problems (host header, health monitors, embedded links) can occur when you load-balance public websites; they are a lot less likely to happen in production because there won't be a firewall blocking pings between Traffic Manager and the local webservers, and the DNS for www.site.com will resolve to a traffic IP address on the Traffic Manager so the host header and embedded links will be correct.
Watch out for situations where the web server sends HTTP redirects to another domain. For example, when I tested by load balancing to www.yahoo.com, the website immediately tried to redirect me to www.uk.yahoo.com (I was based in the UK). You have no control over this behavior by a public website; I configured my Traffic Manager to forward traffic to www.uk.yahoo.com instead.
Now that you have a working load-balancing configuration, you can:
Check out the Activity Monitors and Connections Reports to observe the traffic that Traffic Manager is managing
Start experimenting with some of the examples and use cases from the list in Top Pulse vADC Examples and Use Cases
Read some of the Product Briefs for Traffic Manager to understand how it can manage and control traffic
View full article