Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

RMI - load balancing - NoSuchObjectInTable  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have two machines behind TCP load balancer. Each machine hosts RMI registry on port A, and remote object server on port B. Client sees hostname rmi and ports A and B. When trying to connect, the hostname will be resolved to load balancer and load balancer will route request to one of the machines.
The problem is that first client goes to RMI registry. Load balancer will direct it to random machine and client will obtain stub from that machine. The next step is that client will try to call
server object using the stub provided in previous call. However, the load balancer will route it to another machine where the stub has different remote object Id and the call will fail with NoSuchObjectInTable exception.
So one solution will be to make stickiness on load balancer to route both ports A and B to same machine in case of same source IP address.
But can this be solved on RMI server side somehow so that the both stubs would display same remote object ID?
Thanks.
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tepih,

Do you need to have multiple RMI registries? Can you have the servers share an RMI registry?

Jeff
 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't we restrict the Load balancing to just obtain the stub ,and then invoke the remote service on the stub directly,bypassing the Load balancer? Of course it would reduce the usefulness of the load balancer in terms of distributing the RMI invocations.
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of other points to keep in mind. If you have so many connections that you need a load balancer, RMI may not be the best of choices. Underneath, RMI uses sockets and opens a new connection for each concurrent connection. So if you have so many concurrent requests that you need to load balance, you may have issues with opening too many sockets.

By using a shared registry, you can eliminate the problem of having no such object in the table. But, to improve scalability, you can do some stub caching. For example,

The request is routed to machine A and checks its cache and sees it does not have the stub. It then, and only then, goes to the registry to look it up. Next request to machine A won't require a trip to the registry since the stub will be cached.

You can then apply the same approach to machine B, C, etc. Even though they are sharing a registry, the caching should reduce the number of calls to it.

Hope this helps,
Jeff
 
What's that smell? Hey, sniff this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!