RMi Vs Stateless session
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sashi_reddy
Posted On:   Sunday, May 13, 2001 09:55 AM

What is the case for RMI? I used to do RMI before the EJB era.
Can we not do everything we want to with RMI probably with a
stateless session bean? Why would one use RMI instead of a stateless
session bean? Can someone tell me the advantages, disadvantages etc
of both approaches ? Is there any difference as far as performance is
concerned?

Re: RMi Vs Stateless session

Posted By:   Mikael_Jakobsson  
Posted On:   Wednesday, November 21, 2001 05:19 AM

EJBs are (as I am sure you are aware) a framework for distributed components, handling transactions and object pooling and more.

RMI is used in this framework as the mechanism for object distribution.


An EJB application server adds more to distributed components than RMI does. The application server will handle transactions, object pooling, database connection pooling and more. This extra functionality comes at a price, performance-wise, since there are simply more things to check and handle compared to plain RMI where no such functionality exists.


Therefore, when it comes to comparing performance, EJBs can only be slower than a similar construction using RMI directly, due to the overhead introduced by the application server.


Q: But what if you code all the extra functionality yourself?


A: That depends on what your priorities are. There are at least two ways to look at this:


  • The "Pure RMI" solution would probably be faster, since it is likely to be optimized for the problem at hand.
    The EJB framework is a generic framework that can handle most cases where distributed components are desired. Such generic code needs to perform more checks and needs more layers of logic to handle almost any possible type of problem. These checks and extra layers will introduce some performance overhead. So if your priority is performance, the pure RMI solution will probably be the best solution. To take this to the extreme you could save some extra performance by skipping the (generic) RMI framework and go directly for the Sockets. There is definitely some extra milliseconds to spare there too.
  • The reason for using RMI instead of sockets is often that it is so much easier to distribute components via RMI. The development time is simply much shorter if RMI is used. The same holds true for the EJB vs RMI discussion. If you DO need some functionality that is provided by the application server it is much simpler and quicker to use the existing EJB framework than developing your own functionality for common problems such as DB connection pooling. Using the EJB framework is many times more cost-effective, which is an important parameter in many projects .


I think that there is no "correct answer" to this issue, but I hope the above has added some input in the debate on where and when to use what technology.


Regards,

MiJak

Re: RMi Vs Stateless session

Posted By:   Michael_Wax  
Posted On:   Monday, May 14, 2001 04:22 PM

You can use RMI to do everything that you can do with a stateless session bean. However, the EJB container handles transactions, object pooling, and bean life-cycle management for you, and most containers also will handle database connection pooling for you. Using RMI alone you will need to do these things yourself. On the other hand, if you don't need the services that a container offers, then you probably will see better performance by forgoing the added overhead imposed by the container. In short, the choice between RMI and stateless beans depends on what you are doing, and how much code you want to write yourself.
About | Sitemap | Contact