Tuesday, June 10, 2014

Pooling refer to grouping together resources to minimize risk to the users. In Oracle Service Bus we have concept of Service Pooling. In OSB we can group together more than one service so that whenever one service goes down, request will route to next available service and end user can continue his work without any interruption.

In this post, I will show you how service pooling works in OSB.  For this post we group together three services. Ideally three services should be on different servers located on different locations independent of each other , since I don’t have three different servers so I deployed same service on three different partitions on same server. So here each partition will act like different server.

Service pooling works based on algorithm set by us in business service. In this post, I will show how pooling works when we use “Round Robin” algorithm and we use don’t use any algorithm.

Let’s first talk about round robin algorithm, in this algorithm business service call service in round robin fashion. As shown in figure below if all the services are up then business service will route the first request to first service , second to second service and third request to third service and will continue to do so. But if one of the service is down then business service will take that service out of the pool and continue processing with available services in round robin fashion.



Let’s talk about when we don’t set any algorithm in business service. Here business service will call only first available service out of all available services. If first service is available then it will invoke first but if first service is down then it will invoke next available service and so on. Important point here is that we need to set “retry count” property to make it work.



Let’s move to actual use case. We have two use cases here, first with “round robin” algorithm and second with no algorithm.

First create a simple synchronous SOA composite and deploy it to three different partitions so three different partitions will act like three different servers.


Create a new OSB project and import SOA composite WSDL and schema file to it.

Now create a business service which invoke above created SOA composite.



To enable service pooling, add all available service endpoint in business service endpoint URI.


Create a proxy service based on above created business service.




Round Robin Algorithm

To set round robin algorithm, go to business service and choose “round robin” as load balancing algorithm. This algorithm is used for load balancing.


Now test you use case. Test your proxy service three times so you will see one instance of each service in all three partitions. If you make one service down then you will see one instance of each service only in two partitions.



No Algorithm

Go to business service and choose “none” as load balancing algorithm. Make sure you set “Retry Count”, if you don’t set this property then this scenario will not work.



Testing Result:

Test your proxy service, send two requests and you see that both the request routed to first available composite only.


Let’s shut down the first composite now. Now test the proxy service. You will faulted instance in first partition and successful instance in second partition.


Now let’s shut down first two services. Test your proxy service. You will see two faulted instances in first two partition and successful instance in third partition.




Download code from here.



4 comments :

  1. "Now test you use case. Test your proxy service three times so you will see one instance of each service in all three partitions. If you make one service down then you will see one instance of each service only in two partitions."

    So if we use the above pooling concept, we are actually hitting all 3 servers at the same time ? Why would someone do this, also what will happen to the back-end system as it will get hit 3 times.

    ReplyDelete
  2. Great post!!!!! really loved it...

    ReplyDelete
  3. If I am hitting 3 requests from Proxy Service and one of the SOA composite service is down, then each instance will go to other 2 SOA composite but what about the 3rd Request? it will get lost or it will go to 2nd SOA composite?

    ReplyDelete