Load Balancing ECF Remote Services

In some cases, such services will be long-running and/or computationally intensive, and this can mean that multiple servers can/should be used to actually execute the given service, so as not to use all resource available on a given server. What would be desirable is that the actual remote service request be dynamically load balanced among some arbitary number of servers, so as not to overload a given server instance.

ECF now has an example that uses the ECF ActiveMQ provider to dynamically load balance individual service requests to an arbitrary number of server processes, thereby distributing the load caused by the service requests onto as many server processes as can be made available. The actual load balancing of individual requests is done by using a JMS Queue, which has load balancing semantics built in.

Architecture

This is a very simple service interface, and is meant to be illustrative/example only. Other services will/should be created as appropriate for one's own application.

The load balancing application is structured as follows:

One or more Service Consumers. The service consumer is the actual client of the remote service (in this case, the client of IDataProcessor service).

A single Service Host, which appears to clients as the actual host of the IDataProcessor service, but is actually a JMS queue producer, which puts method invocation requests (received from the consumers) onto a JMS queue.

One or more Service Servers. The service servers are JMS queue message consumers, so that when a service request is put into the JMS queue, it is then delivered to one and only one queue consumers (as per the JMS Queue semantics). Once received, the appropriate method is invoked on a target service implementation object.

The inter-process communication pattern for these three processes is as follows:

Service Consumer(s) <-JMS topic-> Service Host <-JMS Queue-> Service Server(s)

Running the Example

Starting and Configuring ActiveMQ

To run the example, it's necessary to first install ActiveMQ 5.2+. Once installed, start ActiveMQ by going to the <activemq home> directory, and starting ActiveMQ by giving the bin\activemq command in the <activemq home> directory. This will start an instance of ActiveMQ 5.2+.

Use the admin interface create a JMS queue with the following name: exampleQueue

Use the admin interface to create a JMS topic with the following name: exampleTopic

Starting the Service Server(s)

In the org.eclipse.ecf.examples.loadbalancing.server project, open the product config by double clicking on the products/Data Processor Server (activemq).product file in the Eclipse package explorer or the navigator. This should open the Eclipse product configuration editor.

In the lower left of the Overview tab, click on the Launch an Eclipse application or the Launch an Eclipse application in Debug mode links. This should launch the data processor server. Note you can start multiple server instances, but you should have at least one running before starting the service host.

On startup, the service server should produce output to the console like this

Starting the Service Host

In the org.eclipse.ecf.examples.loadbalancing.servicehost project, open the product config by double clicking on the products/Data Processor Service Host (activemq).product file in the Eclipse package explorer or the navigator. This should open the Eclipse product configuration editor.

In the lower left of the Overview tab, click on the Launch an Eclipse application or the Launch an Eclipse application in Debug mode links. This should launch the data processor service host. You should start only a single service host.

On startup, the service host should produce output to the console like this

Running the Service Consumer

In the org.eclipse.ecf.examples.loadbalancing.consumer project, open the product config by double clicking on the products/Data Processor Consumer (activemq).product file in the Eclipse package explorer or the navigator. This should open the Eclipse product configuration editor.

In the lower left of the Overview tab, click on the Launch an Eclipse application or the Launch an Eclipse application in Debug mode links. This should launch the data processor service consumer application.

On startup, the service consumer should produce output to the console like this