2

I was trying to find out if there is any difference when I am calling a service through its local interface / remote interface in performance within the same JVM.

Based on this article: http://www.onjava.com/pub/a/onjava/2004/11/03/localremote.html?page=last&x-showcontent=text Local call should be a bit faster especially in cases for Collection of Objects.

Based on my testing I could not find a big difference between the two however maybe I was trying it with small amount of data.

But anyway I would like to know if it has any downfall to call a service through its remote interface when we are in the same JVM because in my project we are generating both local/remote interfaces however there are no real remote calls, the client and the service is within the same JVM and I am thinking about cleaning up the mess and removing the unnecessary generated remote views because people started to use both without reason.

Thanks!

erik.c
  • 1,342
  • 2
  • 15
  • 27
  • Possible duplicate of [EJB's - when to use Remote and/or local interfaces?](http://stackoverflow.com/questions/3807662/ejbs-when-to-use-remote-and-or-local-interfaces) – amkz Mar 09 '16 at 10:27
  • 2
    This is explicitly asking for performance aspects + details of how containers handle it -> not the same question. – Peter Branforn Jun 29 '16 at 12:07

1 Answers1

2
  • implementation will vary between containers how remote interfaces perform, you cannot rely on it performing similar to local interfaces (though most containers will realize you're actually accessing a 'local' remote interface). There can be differences, like spawning a new thread for the remote call, passing values by reference (you can for example turn this on in jboss for in-vm remote calls), etc
  • serialization is always slow, it should be avoided whenever possible
  • basically just don't do it, absolutely no reason to use the remote interfaces unless you plan on splitting your application into multiple EARs
highstakes
  • 1,499
  • 9
  • 14
  • If you change yout mind and use multiple tiers for EJB/WAR then you can use the @Remote(LocalInterface.class) without multiple interface definitions. Or if you absolutely sure in the single tier solution in the future don't ust use interfaces at all. (no-interface view) – The Bitman Mar 11 '16 at 15:35