There are so many technologies for connecting remote systems that is not trivial take a choice about which one using.
In this post I’d like to put the focus on Spring Rmi and Spring Jax-WS. I wanted to answer only at one question, that’s because it’s very long describe the pro and cons about these technologies; anyway, the question, very typical in IT world is “Which one is the faster ?”.
As I said, we are talking about Remote method invocation (Rmi) and Web services. We are not going to talk about which one is absolutely the best; to answer at this question (whether ever there is only one answer) we should have done more tests and talk about the use case we would apply it.
My test is applied to three different technologies:
- Spring Jax-Ws.
- Rmi calling using rmi protocol
- Rmi calling using http protocol
I used Jmeter to execute the test configured as follow:
- Number of users: 100
- Ramp-up period: 6 seconds
- Duration: 10 minutes
- User calling between 0,5 and 1,5 seconds
To avoid network problem (rmi need to open port) and traffic noise, I made my test at local machine. I didn’t care testing the speed over the network but only the raw technology speed.
Now, the results.
First, Rmi with rmi protocol. The result has been 4 ms.
Second, Rmi with Http protocol. The result has been about 5 ms.
Last, Web Service. The result has been about avarage response of 11 ms with a deviation of 7 ms (almost nothing).
As we had thought, Rmi technology is faster than Web Service (without any big differences between Rmi and Http protocol). The reasons of it are in different serialization system and other different infrastructure system. As I said before, the choice of one depends on the application type that we have to develop. An useful resource for understanding the differences is this table from Ukessays.com.
|Feature||Web Services||Java RMI|
|Distributed garbage collection||No||Yes|
|Interoperable over heterogeneous platforms||Yes||Partial|
|Language independent object/service description||Yes||No|
|Location of objects/services||UDDI||Registry|
|Remote object/service activation||No||Yes|
My personal opinion is to use Rmi when you have to exchange complex object (might in syncronous way) with strong join between server and clients.
I use Web Services when I want to be platform free and I need to share information to unknow client, using a standard protocol (Soap).
So, just take your choice!
Eclipse Client project source code RemotingSpringClient (rename .doc as .zip)
Eclipse Server project source code RemotingSpring (rename .doc as .zip)