Load balancing in Oracle Service Bus (Part 1)

Note: This post was first published before Oracle merged with BEA when the Oracle Service Bus product was known as AquaLogic Service Bus, hence the occasional reference to BEA and AquaLogic Service Bus.

If you have a service you expect to receive heavy usage you may want to consider introducing multiple instances of the service (i.e. multiple service endpoints) and distributing service requests across them in order to share the workload - this is known as load balancing. Out of the box Oracle Service Bus supports a number of different load balancing algorithms:

Round robin - the first request goes to the first service endpoint, the second request to the second service endpoint and so on until all endpoints have been exercised and then the sequence repeats.

Random - each request gets distributed to any one of your service endpoints - over time you would expect each service endpoint to get a similar share of the load

Random weighted - each service endpoint is given a weighting and then service requests are distributed randomly amongst the service endpoints - over time you would expect service requests to be distributed to the service endpoints according to the weighting you have defined

Configuring a load balancing policy for multiple instances of a service in Oracle Service Bus is simple - all you need to do is create a single business service, choose a load balancing algorithm from the list above and define the service endpoints.

Lets walk through how to do this using the Workspace Studio IDE (If you've never used the Workspace Studio IDE before then check out my Oracle Service Bus - Getting started with Workspace Studio post before you start):

- Create an ALSB Project (File>New>ALSB Project) and give it a name - if you have an existing ALSB Configuration Project choose it from the list, if not leave the default setting and one will be created for you.

- Right click on the ALSB Project you have just created and choose New>Business Service

- Give your business service a name, and choose where you want to place your business service in terms of your project and folder structure - by default it will be in the root of the project you right clicked on:

newBusinessServiceWizard

- Then click Next

- Choose the type of service you are creating - for the purpose of this example, I'll choose a WSDL Web Service and select a simple Echo service I have created which simply returns the input message.

newBusinessServiceWizard2

- Click Next

- It is on this page of the wizard you choose your load balancing algorithm and define the multiple endpoints you have. In this case I have chosen round-robin as the load balancing algorithm and defined 2 endpoints:

newBusinessServiceWizard3

- For the purpose of this example, we do not need to perform anymore configuration of our business service so we can just click Finish to complete our business service. To perform more configuration of your business service, select Next.

- Now we've defined our business service we need to publish it to the server, which we do by right clicking on the server in the Servers view and selecting Publish. Note you will need to make sure your endpoints are available too - if you have developed these in Workspace Studio as well then simply right click on the server and choose to Add and Remove projects.

So now we've defined our load balanced business service and deployed it to the runtime - the next step is to test it, right?

Not quite - before we launch the Test Client to try this out lets enable monitoring so we can see our load balancing in action and make sure our requests are correctly being distributed between our service endpoints.

To do this, right click on the server in the Servers view and choose Launch ALSB Administration Console.

Once the ALSB Administration Console opens you need to perform the following steps:

- Click on Create in Change Center to start a new session

- Navigate (either via Resource Browser or Project Explorer) to the business service you have just created and click on it.

- Click on the Operational Settings tab and choose to Enable Monitoring.

- Choose an aggregation interval - this is the time over which monitoring statistics will be aggregated (to calculate things such as average response time) and hence the time you will need to wait to see your metrics in the console - for the purpose of this demo lets choose an aggregation interval of 1 minute.

- Click Update

- Click Activate in the Change Center to complete your session and apply your changes to the server

Now lets test the business service by clicking on the bug icon in the Actions column alongside your business service in the console (you can also launch the Test Client from Workspace Studio by right clicking on the business service and choosing Run As>Run on Server)

- Choose the operation you wish to invoke, enter some valid input data and click Execute. If your business service is a request/response service you should see a response returned.

- Click Back.

- Invoke the test a second time - this should mean that both endpoints are exercised since we have chosen the round-robin load balancing algorithm.

Now click on the Operations link in the left hand navigation of the ALSB Administrative Console. Click on the Service Health tab and you should see your business service listed along with some statistics:

echoServiceHealth 

Note: If you don't see your service listed, check you have enabled monitoring.

Note: If you see your service listed, but don't see any statistics then make sure you have waited for your aggregation interval period.

- Click on the word Online in the Endpoint URI Status column for your business service to drill down to see the metrics for the individual endpoints:

echoServiceHealthDrillDown 

- In this case we chose a load balancing algorithm of round-robin, have 2 distinct service endpoints and have submitted 2 service requests so, as expected, we see each endpoint has serviced 1 message.

Note: If you have chosen a different load balancing algorithm such as random-weighted you will need to submit more requests and probably set a longer aggregation interval to see the number of requests accurately reflect the load balancing algorithm.

So, we have successfully configured, deployed and tested a load balanced business service (and this can be used in the same way as any other business service) - in the next part of this post I will explain how to configure load balancing to automatically handle unreliable service endpoints which may be either online or offline - this is a new feature of Oracle Service Bus v3.0.

Comments:

Hi Chris, You said we need to switch to the admin console in order to enable monitoring. Isn't it possible to enable that using the workshop? Because one we publish anything else from the workshop it will be over written i suppose. If that's the case, In order to have it permanently enabled, Will it be persisted in case I export it from console and import from workshop?

Posted by Nitin on January 02, 2009 at 09:09 AM GMT #

Hi Nitin, The operational settings for a proxy service are held on the runtime server rather than in the design time configuration and so can only be enabled through the administrative console. If you re-publish the service from Workshop it will not overwrite the settings or metrics for the service, however if you move or rename it, it will. Currently, when you export a configuration from the web console, it does not store the operational settings and so these settings will have to be re-applied in the environment which you import the configuration to. I've raised a feature request for us to consider supporting the export/import of operational settings in the future. Hope that helps. Chris

Posted by Chris Tomkins on January 12, 2009 at 09:49 AM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

UK Pre-Sales consultant specialising in business integration.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today