permaculture playing cards
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB3 Remote Performance problem" Watch "EJB3 Remote Performance problem" New topic

EJB3 Remote Performance problem

Ales Dostal

Joined: May 02, 2007
Posts: 4
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("org.omg.CORBA.ORBInitialHost", "");
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:
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

Joined: Feb 05, 2001
Posts: 17276

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.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Ales Dostal

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

But, when is null, resultList has only entity, which contains any 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

Joined: Feb 05, 2001
Posts: 17276

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.

I agree. Here's the link:
subject: EJB3 Remote Performance problem
It's not a secret anymore!