Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3 Remote Performance problem

 
Ales Dostal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ales Dostal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic