Web Farm IP Affinity Load Balancing Algorithm
This blog presents the algorithm for IP affinity load balancing farm publishing in ISA.
Background
ISA Server supports 2 options for load balancing farm web publishing. The first method is session based (aka cookie based), the second method is based on client address affinity (aka source-IP based). In this blog we are focusing on the IP affinity algorithm in detail.
A complete overview of farm load balancing and what method to use is not the scope of this blog. There is a very good overview on this in the product online help.
One tip before going into the specification: IP Affinity is completely inefficient when many remote clients are behind a NAT device, as they all will be routed to the same web server.
Details of algorithm for IP affinity
In order to simplify the implementation of IP Affinity, a solution in a form of a state-less (static) algorithm was chosen.
The motivation behind the algorithm is that all traffic from a specific client will always be routed to the same server in the farm, as long as this server is online. If that server is offline all the traffic from its (potential) clients will be spread equally among the online servers in the farm.
ISA Server maintains an internal state object that keeps two vectors: one which holds references to all published servers in the farm, and one which holds references to only the servers which are currently detected as online.
When a client request is received by ISA Server, at phase #1 the load balancing function calculates a server index as client IP modulo the number of servers in the farm. If the server indexed by this number is online then a reference to this server is returned. This schema assures a fair spread of a consecutive range of IPs to published servers, and the stickiness of that server to the client (as long as the server is online).
If the indexed server is not online (down or “drained”) then the function switches to phase #2. We have to select a server from the list of online servers. For that purpose ISA Server calculates an alternative index that points to a server from the on-line servers’ vector.
The alternative index is calculated according to the following function:
Alternative Index = (Ip / Number_of_published_servers) modulo Number_of_online_servers
When a server goes offline all of its designated traffic is spread equally among the other servers according to this formula.
Note that if there are a few ISA servers in the array (Enterprise Edition only), they all use the same logic, and the vectors are the same. Therefore it doesn’t matter what ISA member in the array receive the request - it will always be routed to the same server in the farm.
Diagram
This schema assures that given a Server A which is down, and a set of client IPs S(A) that were supposed to be mapped to this server, the S(A) spreads equally over the range of on-line servers.
The following chart depicts the above schema:
Adi Kurtz
Senior Development Lead
Forefront TMG
Comments
Anonymous
January 01, 2003
News Security Impersonation and the Access Control List http://co1piltwb.partners.extranet.microsoft.com/mcoeredir/mcoeredirect.aspx?linkId=11918230&s1=68628015-2ccc-cbc7-31b9-0e76c3415474Anonymous
January 01, 2003
Hi, thanks for the nice blog. What about the session affinity algorithm :) and actions done when farm member is drained :) thanks.Anonymous
January 01, 2003
News Security Impersonation and the Access Control List http://co1piltwb.partners.extranet.microsoft.com/mcoeredir/mcoeredirect.aspx?linkId=11918230&s1=68628015-2ccc-cbc7-31b9-0e76c3415474Anonymous
January 01, 2003
242 Microsoft Team blogs searched, 116 blogs have new articles in the past 7 days. 298 new articles found