Reading entity beans from Glassfish too slow [message #527718] |
Fri, 16 April 2010 04:45  |
Eclipse User |
|
|
|
Hi all,
I'm a newbie in Eclipselink and at this time I'm doing some tests. I have created a simple project with 3-layer architecture - swing client, glassfish server and mysql database. The test is simple - in the database I've created a small table (5 columns - id and varchars) with no relations. Using netbeans 6.8 I have created an entitybean like this:
@Entity
@Table(name = "test")
@NamedQueries ...
public class Test implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
...
and a sessionbean with findAll:
public List findAll() {
return em.createNamedQuery("Test.findAll").getResultList();
}
I have inserted 10 000 rows into this table, then I've started a simple swing client on second computer (using JWS). Getting the list of the entites takes about 15 seconds.
Then I've created another method findAllNative:
public List findAllNative() {
return em.createNativeQuery("select * from test").getResultList();
}
and on the client side I have mapped the result list to my own class (is a POJO class with getters and setters). This takes about 2 seconds! (loading and mapping)
So my question is - what I'm doing wrong? I know, that the mapping slows the performance, but so much?
My env: java 1.6.0.18_b07, Netbeans 6.8, Ecplipselink 2.0.0 (v20091127-r5931), Glassfish 2.1.1 ((v2.1 Patch06)(9.1_02 Patch12)) (build b31g-fcs), connection 1Gbps, both computers are dualcores with 4GB RAM, Win XP / Win 7.
Thank you and sorry for my english, I'm not a native speaker 
Thomas
[Updated on: Fri, 16 April 2010 06:08] by Moderator
|
|
|
|
Re: Reading entity beans from Glassfish too slow [message #528602 is a reply to message #528148] |
Wed, 21 April 2010 04:54   |
Eclipse User |
|
|
|
Hi,
thank you for reply!
To the first point - there is no relationship, the whole entityclass:
@Entity
@Table(name = "test")
@NamedQueries(...)
public class Test implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Basic(optional = false)
@Column(name = "param1")
private String param1;
@Basic(optional = false)
@Column(name = "param2")
private String param2;
@Basic(optional = false)
@Column(name = "param3")
private String param3;
@Basic(optional = false)
@Column(name = "param4")
private String param4;
@Lob
@Column(name = "param5")
private String param5;
... // getters and setters
}
I have made some measurements and I think the problem is in the deserialization on client side, because:
- it's only 9 MB of data transported through network, which is very fast -> sending data to client takes only 2 seconds
- after the data are received, the client cpu load goes to 50% (it's dualcore, so I think one whole core is used) for the rest of time...
- at this time I don't set the data to the gui, so there is no gui delay (only a "done" message with time is showed)
The call of the session bean on client side:
Context c = new InitialContext();
return (TestSessionRemote) c.lookup("java:comp/env/TestSessionBean");
The client contains the ejb jar, so it has access to ejb classes.
Is there any way for tunning the deserialization of the entity beans? I don't understand, why it takes needs so much performance on client side.
Thomas
|
|
|
Re: Reading entity beans from Glassfish too slow [message #528617 is a reply to message #528602] |
Wed, 21 April 2010 06:00  |
Eclipse User |
|
|
|
So I have found two solution:
1. Use manual serialization described in:
http://forums.java.net/jive/thread.jspa?messageID=394388
This works great! The time goes down from 14-15 seconds to 0,2! Actually I have a question - why? Why I need to use such manual workaround?
2. Not tested, but there is an option -Dcom.sun.corba.ee.encoding.ORBEnableJavaSerialization, which should be setted to true. But actually I don't know how to set this in my project - swing client is runned using webstart. The JNLP file is generated by glassfish and I don't know how to say the client run with this jvm option.
The second solution is more cleaner, so if somebody knows, how to set this up, please tell me.
Thank you
Thomas
|
|
|
Powered by
FUDForum. Page generated in 0.05617 seconds