HOW TO

Implement load balancing with the ActiveX Connector

Last Published: April 25, 2020

Summary

Unlike the ServletConnector, the ActiveX Connector has no way to natively load balance among Application Servers. There are several options, but the most flexible and widely adopted algorithm is a simple Round-Robin type of load balancing, which keeps a list of the Application Servers, and forwards each request to the next Application Server in the list. Add the following code to the ArcIMS ActiveX Connector application.

Procedure

The sample ASP page demonstrates round-robin load balancing. To run, save the code as an .asp file on the IIS Web server, then edit the function NextAppServer(), adding the names of the Application Servers between which you want to load balance. Additionally, edit the Constant 'MAP_SERVICE' by specifying a valid, running map service on the ArcIMS installation.


Code:

<%@ Language=VBScript %>
<% Option Explicit %>

<%
Const MAP_SERVICE = "SantaClara"
Dim cn, map, url

Set cn = Server.CreateObject("aims.ArcIMSConnector")
cn.ServerName = NextAppServer()
cn.ServerPort = 5300
Set map = Server.CreateObject("aims.Map")
map.InitMap cn, MAP_SERVICE
map.Width = 500
map.Height = 300
map.Refresh
url = map.GetImageAsUrl()
%>
<HTML>
<HEAD>
</HEAD>
<BODY>

<%Response.Write "Using: " & cn.ServerName %>

<P align=center>
<IMG SRC="<% =url %>">
</P>

</BODY>
</HTML>
<%

Function NextAppServer()

Dim lastServerIdx
Dim nextServerIdx, nextServerName


' add Application Servers here
Dim aryAppServers(1) ' 2 app servers
aryAppServers(0) = "APPSERVER_1"
aryAppServers(1) = "APPSERVER_2"

lastServerIdx = Application("svr")
If lastServerIdx = "" Then '1st time
lastServerIdx = LBound(aryAppServers) ' use the first app server
nextServerIdx = lastServerIdx
Else
nextServerIdx = lastServerIdx + 1
If nextServerIdx > UBound(aryAppServers) Then
nextServerIdx = LBound(aryAppServers)
End If
End If


Application.Lock
Application("svr") = nextServerIdx
Application.UnLock
nextServerName = aryAppServers(nextServerIdx)
If nextServerName = "" Then nextServerName = "localhost"
NextAppServer = nextServerName

End Function

%>

Article ID:000006122

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic