Developer Documentation Library > Interviewer - Server > Monitoring and tuning system performance > Load balancing interviewing engines > Examples of UNICOM Intelligence Interviewer load balancing algorithms > Setting PercentLoaded based on memory usage or engine activity
 
Setting PercentLoaded based on memory usage or engine activity
This algorithm sets PercentLoaded equal to memory usage or engine activity, whichever is higher. If there are more than 500 interviews currently running or there are more than 50 errors per second, the algorithm sets PercentLoaded to 100.
Dim ConnectionLimit, RequestLimit, pctLoadedMem, pctLoadedActivity
ConnectionLimit = 100
RequestLimit = 15
' Must deload conditions
If (Engine.ErrorsPerSec > 50) Then
PercentLoaded = 100
ElseIf (Engine.CurrentInterviews > 500) Then
PercentLoaded = 100
Else
' Standard conditions
' What percentage of the Interview Engine's current size compared with the
' size it could grow to?
pctLoadedMem = 100 * Process.MemoryUsage / _
(System.AvailablePhysical - Process.MemoryUsage)
pctLoadedActivity = 100 * ( _
(0.5 * Engine.CurrentInterviews / ConnectionLimit) + _
(0.5 * Engine.RequestsPerSec / RequestLimit)
If (pctLoadedMem > pctLoadedActivity) Then
PercentLoaded = pctLoadedMem
Else
PercentLoaded = pctLoadedActivity
End If
End If
See also
Examples of UNICOM Intelligence Interviewer load balancing algorithms