How to integrate F5 with Web Farm Framework?
Overview
Web farm framework ships with runtime extensibility. You can write your own providers (you can learn more about extending Web farm framework here) and they will be treated as first class citizens of the framework. You can take advantage of the existing providers by making use of dependencies, dependants. Web farm framework ships with Application Request Routing.
Web farm framework has in built extensibility to work with any load balancer. The intent of this article is to show how you can use a load balancer like F5.
Integration with a load balancer like F5 is great with WFF because it allows you to simplify the management and deployment of your web farm (in presence of a load balancer) without having to do these operations manually. These benefits and provisioning details are discussed in more details in WFF detailed walkthroughs.
Through its extensibility model, the Web Farm Framework is able to communicate with the F5 BIG-IP Local Traffic Manager (LTM) through the LTM's open SOAP/XML based API. This API allows WFF to make dynamic configuration changes on the load balancer, such as creating pools, disabling nodes, and re-enabling to make sure connections are not being sent to servers as WFF is updating them. F5 has wrapped their iControl SDK in a .net assembly (icontrol.dll), making integration into WFF a simple procedure.
Resources
All the files are attached to the blog post are available for download. The project file is a class library to produce a dll. All operation providers override the Disposition to make providers internal only. The operation providers just call the utility class to perform load balancer specific operation.
The zip file contains the following files:
- F5AddServerOperationProvider.cs
This operation provider is called whenever a new server is added to the farm. The operation provider changes the state of the server to "disabled". The reason we are changing the state to disabled is because we want to provision the server before adding it to load balancing. The operation does nothing except asking the load balancer to change the state of the newly added server to "disabled".
- F5AddWebFarmOperationProvider.cs
The operation is called by the framework when a new webfarm is created. The operation provider creates the "F5" pool if it does not exist.
- F5DisableLoadBalancingOperationProvider.cs
The operation provider changes the state of the server to "disabled" and is called by the framework in case any operation is executing on the server which needs server to be removed from load balancing. The example of such operations would be Rebooting, WindowsUpdate, and Provisioning etc.
- F5EnableLoadBalancingOperationProvider.cs
The operation provider adds the server back to the load balancing once the executing operation on the server has completed. The operation provider just informs the load balancer to add it back to load balancing.
- F5RemoveServerOperationProvider.cs
The operation provider is called by the framework when the server is removed from the web farm. The operation provider just removed the server from F5 load balancer, so that it no longer participates in serving requests.
- F5RemoveWebFarmOperationProvider.cs
The operation provider is called when the farm is removed from the framework. The operation just removes the farm from the load balancer.
- Utility.cs
The class contains utility methods to interact with the F5 load balancer. The file also contains a class called F5Constants which contain the credentials. You need to change them to work in your environment.
- Resources.resx
This file contains few string resources.
- IControl.dll
The project also references IControl.dll which can be downloaded from http://devcentral.f5.com/.
Details
LoadBalancerProvider in the applicationHost.config file also needs to be changed to "F5" for framework to call custom written load balancer providers whenever it is doing any load balancer related operations. Once the dll (F5LoadBalancer.dll) is produced, the service needs to be stopped and the dll needs to be placed in "%programfiles%\IIS\Microsoft Web Farm Framework\extensions" (create the folder if does not exist). IControl.dll needs to be placed in "%programfiles%/IIS/Microsoft Web Farm Framework"
Now you need to create the farm, go the UI (with the service stopped), and create a farm. You might get "Service Stopped" error when you add the server to the farm.
Just click "Ok" and you will be prompted if you still want to add the server to the farm. Click "Yes" and add the server to the farm. Repeat the process for all the servers.
Currently there is no support for changing the loadBalacerProvider attribute of the webfarm in the UI, so you have to do this step manually. Open applicationHost.config, and navigate to the created webfarm. Add "loadBalancerProvider" attribute and set its value to "F5". The webfarm should now look like
<webFarm name="TestFarm" enabled="true" adminUserName="{0}\administrator" adminPassword="[enc:AesProvider:yABu5gy6pDr7a0n6qV6ASO3ekqq2zO8ZCcC0ZNn5vYo=:enc]" primaryServer="demoprimary" loadBalancerProvider="F5">
<server address="demoprimary" enabled="true" />
<server address="demosecondary" enabled="true" />
<platformProvision syncPlatformFromPrimary="true" />
<applicationProvision syncWebServerFromPrimary="true" />
</webFarm>
Now start the webFarmService (net start webfarmservice) and you will find that a new Pool has been created. In this case, the service has already changed the state of my primary machine to enabled.
Once both the servers have been provisioned, the status of both of them would be change to enabled.
If you're interested in finding out more about F5's iControl API, it is documented on their DevCentral Site, http://devcentral.f5.com/Default.aspx?tabid=76.
To get this to work, you'll need to download their icontroll.dll that can be found here - http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/2/Default.aspx
F5's Microsoft Community Forum can be found here - http://devcentral.f5.com/microsoft
F5 will also be hosting an information page about WFF, and that can be found here - http://devcentral.f5.com/weblogs/rkorock/Default.aspx