• Home
  • RSS Feed
  • Log in

EJAPP Top 10 countdown: #2 – Unnecessary remoting
Posted by Vincent Partington in the late evening: April 25th, 2007

Picking up the pace to make sure I get the countdown finished before I go to JavaOne ;-) , I'll quickly move on to #2 of the EJAPP Top 10 countdown....

While remoting is often used in Enterprise Java applications due to the fact that other systems and applications need to be invoked, unnecessary remoting is an important cause of badly performing Enterprise Java applications.

Therefore this issue can manifest itself in a number of different ways:

  • Invoking a EJB remotely when a local call is available (also a case of incorrect usage of Java EE).
  • Invoking an external application when the functionality is available within Java itself. The code below was discovered in an production source code:
    Runtime.getRuntime().exec("d:\\path\\to\\bin\\sleep.exe " + nbSecond);

    The same functionality could have been gotten with a simple:

    Thread.sleep(nbSecond * 1000);
  • Using SOAP when RMI would suffice. SOAP invocations are typically 10 to 20 times slower than the equivalent RMI invocation, depending upon the SOAP framework used, the network speed, and the time taken on the server by the invoked method itself. See Comparison of performance of web services, WS-security, RMI, and RMI-SSL by Juric, Rozman, Brumen, Colnaric, and Hericko for a scientific case study. In any case, using SOAP can be a case of unnecessary use of XML, which in turn causes excessive memory usage.
  • Invoking a lot of small method calls (fine grained) instead of one large method call (coarse grained), thereby incurring the remote method invocation overhead multiple times. The Transfer Object pattern was invented to solve this problem in JavaEE where it was especially prevalent in EJB 1.x entity beans.

In some cases an architecture is designed with remoting built-in for some anticipated future need that never occurs. For example, a colleague of mine has encountered an application split into two projects: a services layer (providing access to a mainframe) designed for multiple front-ends that could be accessed through a SOAP interface and a web interface invoking the services layer. In the end no other front-ends were built and the whole system was deployed within one application server cluster. The benefits of remoting were not used, but the performance hit was still there. A typical case of YAGNI!

The same thing can be seen in previous version of J2EE; EJB 1.x had only remote beans because that would allow clustering to improve availability and performance, even though that was not always needed. Similarly I can't really get excited about WSRP; I shudder to think about the performance of a portal (not one of my favorite technologies in any case) that invokes it portlets over a SOAP interface.

Anyway, sometimes you just have to deal with remoting. In that case, these tips may help you mitigate the damage:

  • First of all, make sure you really need remoting.
  • Choose your remoting technology wisely. Don't use SOAP because all the cool kids are doing it. ;-) Consider alternatives like Hessian (an efficient binary protocol), Burlap (a XML version of Hessian), Spring's HTTP Invokers (a Java-only binary protocol), or RMI. Write a benchmark for your situation to help you decide.
  • Avoid invoking fine grained methods remotely. Use the Facade pattern to cluster them together to form coarsed grained methods.
  • If remoting is needed for only a part of your use cases, consider exposing your business functionality using different technologies. For example, the Spring framework allows functionality to be invoked by a Java method call while that same functionality is also exposed as a service by an Exporter.

Remoting has its uses and its advantages, just be aware of its implications for the performance of your application!

  • Share/Bookmark

Filed under Java, Performance | 4 Comments »



4 Responses to “EJAPP Top 10 countdown: #2 – Unnecessary remoting”



    Juergen Says:
    Posted at: May 2, 2007 at 9:52 am

    A viable alternative besides RMI for a fast remoting protocol is CORBA. Contrary to all rumors you heard, CORBA has a very fast and efficient network protocol and really is not hard to implement:

    http://java.sun.com/j2se/1.4.2/docs/guide/idl/GShome.html



    Le top 10 des problèmes de performances des applications J2EE par J2EE, AgilitĂ© et SOA : Le blog de Xebia France Says:
    Posted at: May 3, 2007 at 2:38 pm

    [...] #02 – Utilisation abusive de la distribution [...]



    Rejeev Says:
    Posted at: May 25, 2007 at 5:10 am

    Most of the popular Application Servers (Pramati Application Server and Weblogic I know) optimizes the remote calls if the stub and skelton are part of the same application (part of same EAR)



    Xebia Blog Says:
    Posted at: August 17, 2007 at 10:15 am

    [...] Discussed are numbers 2-Unnecessary remoting. More information about number 2 can be found here. and for number 1-Incorrect database usage see; here. [...]



Leave a Reply

Click here to cancel reply.

Deployment automation for Java application running on Websphere, WebLogic and JBoss

Archives

  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009

Training

  • Tackling Top 10 JavaEE Performance Pitfalls
    13 & 14 May 2009

Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India

Categories

  • Java (282)
  • Agile (109)
  • General (50)
  • Testing (42)
  • Performance (42)
  • Hibernate (36)
  • Scrum (33)
  • Podcast (31)
  • Architecture (31)
  • Spring (28)
  • SOA (24)
  • Maven (22)
  • Project Management (22)
  • Middleware (23)
    • Deployment (14)
  • Flex (17)
  • JPA (17)
  • Eclipse (15)
  • Xebia Labs (15)
  • Quality Assurance (14)

Tag Cloud

    Ajax Java Lean Introduction to Agile Spring qcon Architecture Groovy Semantic Web Scala SOA Functional Programming fitnesse Poppendieck Grails XML Closures esb Maven Hibernate IntelliJ JavaOne product owner Scrum Testing Seam Performance Agile Awareness Workshop Xebia Agile