Having developed RMI with a low latency (~ 20 microseconds min), it is still 1000 times slower than a direct call. If you use simple Java RMI, (~ 500 microseconds min), it can be 25,000 times slower.
NOTE. This is a very rough estimate, which will give you a general idea of ββthe difference that you can see. There are many complex factors that can significantly change these numbers. Depending on what this method does, the difference can be much lower: esp, if you are running RMI in the same process, if the network is relatively slow, the difference can be much larger.
In addition, even if there is a very large relative difference, it may not make much difference for your entire application.
Think over my last comment ...
Suppose you have a GUI that needs to poll some data every second, and a background thread is used for this. Assume that using RMI takes 50 ms, and the alternative makes a direct call to the local copy method of the distributed cache takes 0,0005 ms. It would seem that this is a huge difference, 100 000x. However, the RMI call may start 50 ms earlier, still polling every second, the difference with the user is almost nothing.
Which can be much more important when RMI compared to using another approach is much simpler (if its the right tool for the job)
An alternative to using RMI is to use JMS. It best depends on your situation.
source share