Configuring autodiscovery

Autodiscovery can be used in a 2 tier system with multiple application servers to automatically direct a user to the appropriate application server or servers. To handle the case of the failure of an application server, the client can be given a list of servers to try in turn.

To use autodiscovery the client should be started in a special mode using the -K command line switch. This causes it to locate a master connection manager and request from it the server(s) that a given user should be using.

Determining the master connection manager

The client locates the master connection manager by looking for a server called ksad in the local DNS. This can be an alias for a server with some other canonical name. For resilience you may wish to set up a round robin by having several servers with that name.

Determining the application server to use

The connection manager uses a static load balancing scheme based on a list of users for a given server failover group. A server failover group is one or more appplication servers that are tried in turn. For instance in a two application server setup you would have two groups with each server heading its group and the other server acting as the backup. The list of servers and the allocation of users to the servers is handled by the K8 application which generates a text file, called the hosts file, in a shared directory visible to the connection manager(s).

The file format has one line per user. Comments are allowed after a # sign. Blank lines are ignored. Each userid is followed by a comma and one or more comma separated server names or IP addresses.

# Load balance list generated at 15:18:54 on 14/11/2006
# Users from Newbury branch 0001
pjc,apps1,apps2
fredb,apps1,apps2
joe.soap,apps1,apps2
# Users from Hungerford branch 0002
tblair,apps2,apps1
gbrown,apps2,apps1
dcameron,apps2,apps1
...

If the user ID contains a wild card character, then pattern matching will be used.

# Load balance list generated at 15:18:54 on 14/11/2006
# Users from Newbury branch 0001
pjc,apps1,apps2
fredb,apps1,apps2
joe.soap,apps1,apps2
kcc*,apps2,app1

Against each applicable <service> in the <services> section of kconf.xml you can add a <ksad> section containing a <hosts> tag specifying the location of the hosts file for that service. You can also associate an image with the service using the <image> tag. This image will be used if more than one service is applicable and is associated with the service name in the services menu. The image's URL can either be relative to the Connection Manager's web root, or use a <service's> alias. Environment variables, such as $SERVICE, will be expanded.

<service>
	<name>K8BENCH_local</name>
	<type>oracle</type>
	<catalogue>/fidel/k8bench/data/k8bench_cat.kdb</catalogue>
	<description>K8BENCH: K8 Oracle Benchmark System</description>
	<kcmltype>6</kcmltype>
	<global_id>1001</global_id>
	<connection>true</connection>
	<ksad>
		<image>$SERVICE/Help/Images/K8HelpBack.png</image>
		<hosts>/K8shared/work/hosts.txt</hosts>
	</ksad>
	...

Use a web page as a service menu

Rather than using the default services list you can merge the list into an existing web page to act as a portal. The location of a template web page is specified using the <ksad> tag in the <general> section of kconf.xml e.g.

<general>
	...
	<ksad>
		<homepage>/home/atlas/home.htm</homepage>
	</ksad>
	...

The location is with respect to the web root.The service display will scan this document looking for a <div> tag with an id of KCMLConnections and add the services to it.

<div id="KCMLConnections"></div>

If it can't find the div the services list will be added at the end of the document.

A style sheet can be used to help format the service list. An example stylesheet, ksad.css is installed in the web root.

Static load balancing in database clusters

There are great advantages to having users likely to generate common SQL on the same node of a database cluster to maximize caching. One way to do this is to have the application add the suggested database nodes onto the failover list following a semicolon.

# Load balance list generated at 15:18:54 on 14/11/2006
# Users from Newbury branch 0001
pjc,apps1,apps2;$RAC1,$RAC2
fredb,apps1,apps2;$RAC1,$RAC2
joe.soap,apps1,apps2;$RAC1,$RAC2
# Users from Hungerford branch 0002
tblair,apps2,apps1;$RAC1,$RAC2
gbrown,apps2,apps1;$RAC1,$RAC2
dcameron,apps2,apps1;$RAC1,$RAC2
...

These will be picked up by the client and forwarded to the Connection Manager on the target apps server allowing it to create an environment variable called KCML_DB_CONNECT containing the string that follows the semicolon. If there was no semicolon and no string then the environment variable will not exist. The application can use that variable to generate the correct DSN to use in KI_CONNECT.

The actual connect strings should be defined in kconf.xml using environment variables and those variable are what should appear in the load balance list.

See Also:

Autodiscovery in the client