Java: RMI vs Web Services
Asked Answered
J

6

10

I need to create a distributed application consisting of multiple clients that send files (plus info about files) to one server, also query that server.

Clients must access to that Web Server from inside the company for sending the files. But, occasionally some specific queries must run outside the company.

I think, given what I know, that RMI is a faster(operating performance) way to connect the desktop client with the indexing engine plus the storage engine. And I believe that making a Web Service that provide an access layer to the search engine is also a good decision, because it will be running outside company's network.

What do you think about it? Is a good approach or do you have some alternatives must be considered.

Thank you in advance.

Jinajingle answered 21/12, 2009 at 17:31 Comment(1)
To answer the question something is missing: What kind of clients are calling up your service? RMI is restricted to java-clients. Webservices on the other hand (I guess with webservices you mean SOAP over HTTP?) are more interoperable (XML based).Expanse
P
8

RMI can be tunnelled over HTTP (see here), so don't let that influence your decision too much.

If both ends can talk RMI, then RMI is probably what you should use; it's a lot easier to get working than a web service.

Penland answered 21/12, 2009 at 17:41 Comment(0)
T
7

Be careful here, I developed a similar solution recently and found that sockets were the most efficient and perfomant way to transfer files, while RMI was good for simple method calls (like queries). I also had a hard time setting up RMI, the configuration can be confusing sometimes and there is not much documentation out there on the subject.

I certainly believe RMI will give you better performance over web services; but web services will probably be more maintainable and flexible for future requirements.

Thundersquall answered 24/12, 2009 at 4:35 Comment(2)
Thank you, I will be careful, is seems like the configuring time is also a hard work. I have had a hard work by now... but it seems that with few test data, works well.Jinajingle
Also found this plug-in to be invaluable for configuring and debugging RMI: genady.net/rmi/index.htmlThundersquall
C
5

What makes you think that RMI is faster? From my experience, it can be slow, difficult to configure, difficult to secure and generally unpleasant to work with.

Since web services are generally just XML over HTTP, you can generally architect a solution that will scale better.

Communard answered 21/12, 2009 at 17:41 Comment(3)
From my experience is what I have seen, but I was not sure, thats why I asked for. See this paper, is one of some performance studies: mercury.it.swin.edu.au/ctg/AWSA04/Papers/gray.pdf, thanks :)Jinajingle
I don't have direct anecdotal evidence, but it makes sense that web services would be, in general, less performant than RMI (primarily due to the extra overhead of parsing into and out of XML, and the additional verbosity of XML over a binary serialization.)Ballonet
@Communard Web-services can be quite a bit more than "just" XML over HTTP.Lima
D
3

If the API you want to support with the service does not map nicely to HTTP, I would probably choose for RMI (but beware of unnecessary roundtrips.)

If it does map onto HTTP nicely, I would chose to go with REST which is essentially HTTP Servlets implementing your API as actions. If most of the traffic is the uploading / downloading of the files you mention combined with a few API calls, this is probably the way to go.

Btw, your experience that RMI is faster than web-services coincides with mine. (Both can be implemented with slow performance as a result, mainly to do with roundtrips in a poorly designed API.)

Delagarza answered 21/12, 2009 at 17:56 Comment(0)
B
3

It's never ending debate anyway. Here is my humble opinion:

  • The web services do allow a loose coupled architecture. With RMI, you have to compile everything even if there was smallest change (because of class serial UUIDs and whatever).
  • WS allow easier coexistence with other enterprise components (ESB, SSO, Identity Management, load balancing, security filters, security certificates) as HTTP is underlying network protocol.
  • Reflection in RMI (and in EJB) seems to be more expensive than HTTP protocol itself.

If you are thinking of EJB as more suitable for application server environment and easyer to compare with WS and CORBA according your article, (EJB supports transaction management, bean management; WS have WS+ extensions (security, transactions)):

  • EJB are slower than WS according article: Remote EJB is 3x slower than WebService in 7.1
  • when compiling/building EJBs we had to use exactly same version of application server including patches on dev and production to avoid dubious production run-time errors (this only looks easy - production (datacenter) team doesn't always say which patch they have, when we make fixes for application we always have to re-ask exact version of server).
  • partial fixes of application are not so easy, if EJB is rebuilt due to small fix, client jars has to be rebuilt, therefore applications that use client jars needs redeployment.

(These were problems from my experience, maybe other people were more lucky)

I would conclude that WebServices are more flexible, use less reflection, and hopefully faster if designed carefully. If RESTful is used in MVC controller as result, ESB can help with both offering transformations (less code, just transform) and security injection straight into HTTP headers (e.g. ivheader, ivgroup - if using ibm web seal, Tivoli access manager). Using SAML XACML is possible only when using WS as assertions work with XML. Therefore for distributed and dislocated enterprise applications WS are more flexible due to above mentioned.

Article you refer says that WS have no transactions but only proposals. The article is wrong or too old. See OASIS WSAT 1.0 and WSAT 2.0. Microsoft, JBoss, Oracle and few others support technology out of the box in their application servers. Apache Metro seems to support it was well (please verify).

Boyne answered 22/7, 2014 at 11:14 Comment(1)
Good comparative suggestions. It helped me! Thanks :)Coimbatore
E
1

RMI is basically for small applications . Yes it is faster but over the time you will feel that in order to do more enhancement in your application when the traffic increases , webservice is more maintainable than RMI and if you choose REStFull webservice that will be the best option.

Thanks

Exclamation answered 26/6, 2015 at 15:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.