If the RMI client & server are located on the same machine, what is the overhead of invoking remote method in this situation compared to a local method call? Will the call go through the entire TCP/IP stack, stub and skeleton or will it will be treated as a local invocation?

swarraj kulkarni

Even if you have RMI server and Client on your local machine, to work with them in RMI style, you will have to invoke them as different processes (i.e. with each running within a separate JVM instance).

This scenario is comparable to running the RMI client and server processes in a distributed mode (with each running on a separate machine), where the communication takes place by going through the entire TCP/IP stack, stub and skeleton. Thus, RMI calls between the client and server running on the same machine will not be treated as a local invocation. The overhead here is obvious, and the performance will be relatively poor compared to socket-based communication.