Managing Performance

The decision to use EJB components in an enterprise application brings with it many benefits, as previously described. However, one area which you always need to keep an eye on when dealing with EJBs is their affect on the overall performance of the enterprise application.

EJBs in general make use of Remote Method Invocation (RMI) under the covers to effectively arrive at the separation of interface and implementation. The benefit is easier development of distributed applications and the ability to split the EJB workload over any number of different machines. Your enterprise application might have a session EJB instance running on one machine, whereas the entity objects and databases are somewhere else. By using EJBs with this remote capability automatically built in, the developer doesn't need to know how everything will eventually be deployed.

The drawback to this scheme is that a remote call is always more expensive, both time- and resource-wise, as compared to a call to a local object. As far as J2EE 1.2 is concerned, there are no alternatives to remote access. However, J2EE 1.3 is expected to support the concept of a local client, which we discuss in “The Local Client” section below.

Minimizing Remote Calls

So if remote calls are expensive, and there is no way around using them, how do you maximize your performance?

The primary rule to follow is to keep the number of EJB calls that you need to make to an absolute minimum. For example, if your session bean has three different tasks it needs to handle to support a request from a servlet, these should be rolled together into a single business method on the session bean for the servlet to call. Often this means that internally all this new business method does is call the other three methods directly. The point is you have now dropped the number of remote calls necessary to support this task by two.

The use of JavaBeans, as described earlier, can assist in lowering the total number of necessary remote calls as well.

In addition, different application servers also offer several different mechanisms to preallocate and pool resources, tune settings, and balance server loads to try to maximize the overall performance of your application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.53.93