Many load balancers now allow you to specify a location of a script to run that will tell the load balancer how busy a particular server is. This is called Adaptive Load balancing. I highly recommend using the Adaptive LB setting rather then Round Robin, or Weighted. Reasoning is that if you have an array of servers, 1 server may be performing a rather expensive task then the others, so you don’t want the Load Balancer throwing traffic at it if it is busy. You want the load balancer to make a decision as to which server is the best able to handle the connection. The ColdFusion script below will access CF JVM memory and report a number 0 – 99 that determines how busy it is. 0 being no connections 99 being busy. any number such as 101 and 102 usually is a reserved number for the Load balancer to know that you want to do a drainstop for that server. So i have an admin that i select a server to remove from the array, and it writes a 102 to a text file that the load script reads an passes on to the load balancer.

Once the load balancer querys that page it sees the 101- or 102 and begins draining connections from that server and pushing the connections to another. Note, that if you have sticky sessions, it may take a while to drain connections based on how long you keep connections persistant.

EX:

 <cfif fileExists('#expandPath('\load\adminDown.txt')#')>

<cffile action="read" file="#expandPath('\load\adminDown.txt')#" variable="return">

<cfset returnNum = trim(return)>

<cfelse>

<cfset returnNum = ''>

</cfif>

<cfif returnNum EQ ''>

<cfinvoke component="cfide.adminapi.administrator" method="login" adminPassword="password"/>

<cfinvoke component="cfide.adminapi.servermonitoring" method="getHeartbeat" returnVariable="result">

<cfset returnNum = (result["usedMemory"] / (result["usedMemory"] + result["freeMemory"])) * 100>

<cfif round(returnNum) GTE 100>

99

<cfelse>

<cfoutput>#round(returnNum)#</cfoutput>

</cfif>

<cfelse>

<cfoutput>#returnNum#</cfoutput>

</cfif>