views:

67

answers:

2

Hi,

Well We have situation to decide now. I thought stackoverflow is best place to discuss.

Background:

We have 2 JVMs Enterprise Application server and one application deployed on each of them. we need to enable the business functionality invocation from one machine to other. Let assume one is client and another is server.

Now from the performance point view which approach is better to design server application.

by keeping following things in mind:

I have 2 options:

  1. Pure EJB application means EJB client and EJB server component

  2. WebService Plain Java approach (no webservice over EJB, coz it is simply mess)

My Performance metrics: Speed : which design approach will process a request faster. My business application will be deployed on 32 bit machine for sure!

Also note that there is 2 JVMs, one is 32 bit and 64 Bit (avoiding this situation is unavoidable right now)

Please provide your feedback

Regards

Chetan

+2  A: 

If by "Web Services" you mean SOAP web services, EJBs should be faster no matter how you do it.

Pros:

  • Java serialization is faster that XML Web Services
  • Serializing and parsing XML uses more memory than straight serialization, EJBs save memory
  • EJBs are expressed in straight Java interfaces and value objects. For Web Services, you might have to add a mapping layer such as XmlBeans or JAXB.
  • Most EJB protocols lets you easily reuse the TCP/IP connections between calls

Cons:

  • Doing a proper design first XML message definition will decouple the client and server
  • It is easier to change the message formats given that extra layer of indirection
  • EJB implementations have historically been huge and slow, as in bigger than Web Service stacks (but newer EJB implementations like Apache OpenEJB are small, lightweight and embeddable)

But if you don't need distributed transaction handling, just use RMI. It has the pros but none of the cons of EJBs. It's been around for ages, but it still works just dandy.

JesperSM
thanks a lot for the details..I am looking for a faster way of communication between 2 JVM. EJB is the one I feel. especially in my application I dont want to loose my performance because of XML parsing at the either ends.
Chetan
+1  A: 

It doesn't have to be one or the other. You can have all your business logic in EJBs, and also provide a web service facade to access the EJB. Also remember that there are different types of web service architectures. SOAP is what most people think of when they hear "web service", but you might also want to look at JAX-RS.

Sending data as XML over HTTP is horribly inefficient. On the other hand, it gives you much more flexibility on the client side. Web services can be consumed from just about any platform or programming language.

Mike Baranczak
thanks mike. If i take SOAP over EJB, XML processing would hamper my performance a lot. coz my xml payload would be around around 60 to 100KB mostly.
Chetan
Mike suggests JAX-RS which sends XML not SOAP messages. For an example see: http://bdoughan.blogspot.com/2010/08/creating-restful-web-service-part-45.html
Blaise Doughan