For best server calculation it uses average request response times.
Here is what I could find related to this Best server algorithm (from very old technote ). There may have been few variation in the recent agent versions.
Best Server Algorithm
The algorithm maintains the distribution table for each policy server. The distribution table contains 2 variables – capacity and throughput. The web agent compares the current capacity of all the policy servers and one with the highest value is considered to be the best. When best server is computed using the above algorithm to serve the current request from WA, then throughput of the best PS is subtracted from its current capacity. That means after serving the request, capacity of the PS comes out to be previous capacity minus current throughput of PS.
Before we have a look at the algorithm, let us first understand the recalibration logic (This recalibration logic is used by best server algorithm)
Recalibration Logic
“The recalibration logic first resets the distribution variables of the policy servers to 0. Then it calculates the throughput for all the active policy servers. The distribution variables for inactive policy servers remain at 0.
The throughput is calculated as inversely to the response time of the policy server. Also the web agent calculates the total throughput i.e. throughput of all the policy servers. The final throughput of the policy server is computed as the ratio between the total throughput and the server throughput (calculated above).
Next, the web agent sets the capacity of all the active policy servers to 100. (The capacity of inactive servers remain at 0.)”
Now, here is how the best server algorithm works:
Initially, the distribution variables of the policy servers are reset to 0. The request processing code (called when request is received by web agent) invokes best server algorithm to select the server which will be serving the current request.
In best server algorithm, web agent iterates through the list of all the policy servers (in a cluster). If capacity of some inactive policy server is found to be greater than 0, then recalibration logic is invoked – this will eventually reset the capacity of inactive PS to 0 and other active PS will have capacity set to 100.
One with the highest capacity is considered to be the best policy server – here web agent initially sets the first policy server as the best server and then if subsequent PS in the list has greater capacity- it is considered as the best and so on till the end of the list of the policy servers.
Now in the end, if the capacity of the best PS comes out to be <=0, then recalibration logic is invoked. If still the capacity of best server remains at <= 0, then an error is returned. Otherwise, upon success, current request is served by this best server and distribution values of the best server are adjusted - basically throughput is subtracted from capacity as mentioned above.
The above algorithm offers following advantages:
- Since response time is taken into account for load balancing, this makes sure that at any point of time, request will be served by the best available policy server
- Since after serving the request, throughput of PS is subtracted from it capacity – this makes sure that requests are distributed in a round robin fashion (since PS with highest capacity is considered to be the best)
Apart from above algorithm, an independent management thread takes care that if some policy server comes into an active state (from an inactive state) – then also recalibration logic is invoked – this will make sure that the capacity of this newly active server is set to 100 and it also starts serving the request.
Illustration
Suppose there are 3 policy servers in an active state – PS1, PS2, PS3
As per the above algorithm, the requests will be distributed between these 3 policy servers depending on their capacity. If suppose PS1 goes down, then recalibration logic will mark its capacity as 0 and subsequent requests will not be forwarded to that PS. The subsequent requests will be distributed between rest of 2 PS – PS2 and PS3 (again depending on their capacity). If PS1 is started again, then management thread will call recalibration logic to mark its capacity to 100 so that this newly active server also starts receiving the requests.