aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB3 Remote Performance problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB3 Remote Performance problem" Watch "EJB3 Remote Performance problem" New topic
Author

EJB3 Remote Performance problem

Ales Dostal
Greenhorn

Joined: May 02, 2007
Posts: 4
Hi,
I use Sun Java App Server 9.0_01 (build b02-p01), mysql 5.0, JTA, EJB3, JPA and Swing Client.

When a call remote EJB:
Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.59");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ic = new InitialContext(props);
RemoteUzivatele remote = (RemoteUzivatele) ic.lookup("EJBTest");

It's OK. But when I call some method, which return some rows from DB, is performance very very poor

When I try on my local machine, where running glassfish and swing client, is performance good.
When I try call from remote machine, where running glassfish and try start swing client on local machine is performance very poor

Remote EJB is:
@PersistenceContext
private EntityManager em;
public List<StrediskaDetail> getStrediska() {
return em.createQuery("SELECT s FROM StrediskaDetail s").getResultList();
}

When I try return only few rows (10-20) is performance good, but when I try return 100-200 rows is performance very poor

Can you help me?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Ales, performance tuning is an art in and of itself, and bad performance can be the result of about 100 different things in your example alone.

Here are some basic guidelines.


1. Only bring down enough data as you need, no more.
2. Finely tune your database access code.
3. Keep remote calls to a minimum.
4. Keep io/network calls to a minimum.


Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ales Dostal
Greenhorn

Joined: May 02, 2007
Posts: 4
Do you mean DTO?
I try my own DTO from entity:


But, when is provoz.name null, resultList has only entity, which contains any provoz.name. How can I return all rows?

Fetch Type
I know, that in glassfish are relations mapped as FetchType=LAZY (default). But, when I call:
from EJB to stand-alone client, I get full collections for OneToMany (It's FetchType=EAGER, not LAZY).

Thanks for your explain
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Well you are using EJB3 and JPA, so DTOs are no longer needed, the JPA mapped classes are now your "DTO" classes. DTO was an anti-pattern designed to get passed the fact that before EJB3, you could not send an Entity Bean to your client because it was Serializable.

So you definitely want to be aware of your queries and what is lazy and what is eager. And You might need more than one version of your query, one being lazy and one being eager, so that the use cases that don't need the eager fetching doesn't bring down that extra data.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB3 Remote Performance problem