my dog learned polymorphism*
The moose likes Distributed Java and the fly likes Using RMI vs Socket programming Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Using RMI vs Socket programming" Watch "Using RMI vs Socket programming" New topic
Author

Using RMI vs Socket programming

Anoop Isaac
Greenhorn

Joined: May 20, 2008
Posts: 3
Hi,
I have 4 web server instances running on the same machine behind a load balancer. All the instances are serving the same application. I want a module taken out the of these 4 instances and run it as a separate service, so that i can reduce the load on the above 4 instances.This service needs to send back a simple json response after doing some index search,service is not exposed to any outside client. So given this simple requirement, what would be the best solution to implement the new service, mainly considering performance . Will it be RMI or socket programming or is there any other solution. Will I have to sacrifice performance if I go for RMI instead of socket programming?

Thanks
Anoop
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

I am not able to understand why socket programming is needed here. Maybe I am not getting the requirement correct.
Why not have a firewall to block anything that is not allowed to access?
Its easy, decoupled and configurable from my point of view.

Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
multiple webservers running on the same machine.


Really? Multiple web servers? - How do you sort out the ports?

Or do you mean one web server with multiple web applications?

How big is the user load?

Bill
Anoop Isaac
Greenhorn

Joined: May 20, 2008
Posts: 3
Amit Ghorpade wrote:I am not able to understand why socket programming is needed here. Maybe I am not getting the requirement correct.
Why not have a firewall to block anything that is not allowed to access?
Its easy, decoupled and configurable from my point of view.

Hope this helps
As I said, we already have for web server instances running on the same machine behind a load balancer. All the instances are having the same application deployed. I want to take a module out of this 4 instances and run it as a separate services so that I can reduce load on server instances. All the server instances will communicate with this new service to get response.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I'd probably use a RESTful web service for this. I can't really think of any reason why I'd use RMI these days, or bother with sockets. The prevalent REST libraries (like Jersey) make both the client and server side pretty easy to develop.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Anoop Isaac wrote:we already have for web server instances running on the same machine behind a load balancer.


I can't imagine any reason to do such a thing. You use a load balancer to spread load between separate machines. It makes no sense to run 4 instances on one box and load balance between them. You lose all sharing of state, etc.

Further, I agree with Tim, there is no reason to use RMI in this case. Don't do it.
 
wood burning stoves
 
subject: Using RMI vs Socket programming