PDA

View Full Version : How to improve RPC performance



livinglegends
17 Jul 2009, 4:35 AM
Hi,

I am working on big project in which I am using many components of EXT-GWT. All are working fine but my main concern in speed.

In my application,

1. I have one module in which I am using TreeTable component. Now, when I open this module it will make RPC call to server.
2. At server side, I have code in hibernate which will fetch data from database, create one POJO class for one record and finally return List of POJOs to client ( 100 POJOs - It will increase in future).
3. At client side, these data will be set in TreeTable component.

All the above steps client->server->client are taking 14-15 sec. to complete.

It is taking 8-9 sec. to return List of POJOs from server to client back and 4-5 sec. to set returned List of POJOs to TreeTable.

Is there any way to improve performance of RPC so I can get data within 2-3 sec.

Hope, I am clear to you. Please give me suggestions or guidance to achieve speed.

sven
17 Jul 2009, 4:38 AM
For the TreeTable rendering: TreeTable is not the fastest one. That is why we replaced it with the TreeGrid. I suggest to change to the TreeGrid.

RPC calls should not take 5 secs for only 100 objects. Is it possible that this objects have many inner objects or big lists?

livinglegends
17 Jul 2009, 4:48 AM
Thanks for your quick reply

Yes ideally it should not take but it is taking and I don't have other object or list in it.

But, how to deal with it if I have reference of other object in it?

How many changes do I need to migrate from TreeTable to TreeGrid?

livinglegends
21 Jul 2009, 2:05 AM
For the TreeTable rendering: TreeTable is not the fastest one. That is why we replaced it with the TreeGrid. I suggest to change to the TreeGrid.
How many changes do I need to apply to migrate from TreeTable to TreeGrid?

RPC calls should not take 5 secs for only 100 objects. Is it possible that this objects have many inner objects or big lists?
Yes ideally it should not take but it is taking and I don't have other object or list in it.

But, how to deal with it if I have reference of other object in it?

jadrake75
21 Jul 2009, 8:09 PM
Wow those are some pretty slow timings..... I do not use RPC, I use Restful WebServices (basically Servlets in Jersey) and output JSON. My web services access my JPA backing store using EclipseLink. So similiar except I am using RequestBuilder to do my AJAX call and I am responsible for converting my POJO to JSON.

On startup I need to load ~ 5 stores (key preferences, albums, collections, countries and catalogues) and it does so in an aggregated 1.5 seconds of "network" time. (I have 98 countries, the others are typically 10 or less). This is browser request/response AJAX time. Time to render these is negligble (only the TreePanel takes any time and it builds remarkably fast compared to the old Tree widget). It took 500-700 milliseconds to recieve 50 objects / page upon choosing a filter and the "render" time is probably < 1.0 second to render the grid (50 rows with 8 columns). I should also mention, the objects in this table are not a simple bean but have relationships to other beans as well as foreign references and these are needed to render some of the columns (for example the bean contains the country id as a foreign key, and the country name comes from the country store loaded at startup) Generally speaking, parsing the JSON into beans is the slowest part but if you are using Chrome, Firefox 3.5 or even IE8 this is faster (Chrome is lightening fast!) If I turn off paging and download all 1000 objects for one grid "view", the objects are downloaded in ~ 2.0 seconds and the display will take longer (as long as 25 seconds on IE7 - I think it was something like 7-8 seconds in Firefox 3.0). This is part of the reason for the switch the paging. The disadvantage for me right now, is because many of my columns do not have a natural sort order, I need to server sort where I have this logic already coded. But even this I did a few things like request the next page upon completion of the current page to cache so that I have it ready for the next request, things like that.

My app is small (datawise) only because it is dependent on my entering more of the data, but I have approximately 7000 items I will display to the user (in a few panels) etc. and rarely is there ever more than a 2.0 sec delay for anything (this is accessing my server in my basement over a cable modem from a remote location) If you really have to display a "report" of stuff (trust me I understand - I develop PDM systems in my day job! Try displaying the product structure for an aircraft) You'll need to squeeze every last CPU cycle and try and push the penalty to the client browser (ie. get a faster machine = faster display). If you are working on a little more mundane client, then try and think of ways to do more and display less (ie. paging, scrolling tables, don't get a tree store and then make a query for N stores representing the types in the tree etc.)

-Jason

livinglegends
21 Jul 2009, 8:40 PM
Hi,

My limitation is that I have to use only GWT-RPC to retrieve data from server and I am returning List of POJOs from server.

So, is there any way to improve performace of GWT-RPC? I want to return List of POJOs only so I can't use JSON.

Colin Alworth
23 Jul 2009, 12:37 PM
Take a look in Firebug to see how big the actual size of the transfer is - a page I am working on pulls down and deals with 13k of objects in just over two seconds, and renders all of the data in about another two.

As Sven asked, are there a lot of other objects that each of those 100 objects has as properties? And can you switch to some other display than a TreeTable?

livinglegends
23 Jul 2009, 9:00 PM
Take a look in Firebug to see how big the actual size of the transfer is - a page I am working on pulls down and deals with 13k of objects in just over two seconds, and renders all of the data in about another two.

I checked size of data in response by checking content size in firebug.
It is only 3935 means 3kb.
I surprised why it is taking time for such small data.
Can you provide any comments or suggestion in this?


As Sven asked, are there a lot of other objects that each of those 100 objects has as properties? And can you switch to some other display than a TreeTable?

Your suggestion to transfer from TreeTable is really useful but practically
it is not feasible to shift from TreeTable to other component say TreeGrid.
I have done certain R&D on TreeGrid and came on conclusion that
I need to change code and flow to shift to TreeGrid and
my project is little bit typical so it might be possible that it will create
some more bugs.

Colin Alworth
24 Jul 2009, 8:42 AM
3k is nothing - the delay you are experiencing is your js processing and rendering. If you aren't willing to change your code, then there isn't much else I can suggest that you do... Slow UI code is slow, and superficial changes cannot fix that.

livinglegends
26 Jul 2009, 10:17 PM
But I have noticed time when server call happened and time when I got complete list of POJOs from the server. The difference between these two times show me that this server call is taking 10-12 seconds. After it data rendering comes in pictures in which js comes in pictures.

Colin Alworth
27 Jul 2009, 4:42 AM
I am assuming you are running from localhost, in which case bandwidth is not an issue. I also assume that you are referring to speeds in web mode, because hosted mode is unnecessarily slow due to all of the java<->javascript translation going on.

That being said, you either have some monster client side processing, or your server is taking a very long time to respond. No browser should be taking that long to turn 3k of very nearly json into an object graph. Try printing current time to the console at the beginning and end of the RPC call to demonstrate where the slowdown is actually taking place.

livinglegends
27 Jul 2009, 5:16 AM
Yes, your assumption is right. I am running from local host in browser in in hosted mode.

I have tried to print time same way. I have printed time when I call server method using RPC and printed time in onSuccess method where I got return back from server. These two times difference show me such long value (10-12 seconds).

Colin Alworth
27 Jul 2009, 5:38 AM
First, hosted mode is _not_ a good way to test performance. Any values you get there are useless for benchmarking. Compile to web mode, and try again.

Second, it doesnt matter when you call the server and when the server returns - I am saying that you should add these timestamp calls to the server code itself, to see how slow your _server_ is, to see if perhaps it is the source of your issues, not GWT or any of its systems.

livinglegends
27 Jul 2009, 8:49 PM
Actually previous message was typo error. I am not running in hosted mode.

I have printed time at all possible places to check the time eat by application. I have printed it in blow places.

1. Where server call happens at client side (t1 secs).
2. At server side in class where all server methods has been implemented (t2 secs).
3. At server side where control ready to return resulting List Of POJOs (t3 secs).
4. At client side in onSuccess method (t4 secs).

I have checked the elapsed time at all places.

1. At server side it takes 7-8 seconds to generate List Of POJOs by retrieving data from database. (t3 - t2 seconds)

2. It takes 12-15 seconds to return generated List to client. (t4-t1 seconds).

Hope you got my point

Colin Alworth
28 Jul 2009, 4:02 AM
Okay. So this means that the server is producing 7-8 seconds of delay - that is your problem. That leaves 5-7 seconds of delay in Hosted mode.

Again, please verify using Web mode - running in Hosted Mode givens nice benchmarks since you can call System.out.println, but there is extra overhead as well. I would be very surprised if your code took longer than 10 seconds (8 on server + 2 on client) once you ran in web mode.

HTH,
Colin

EDIT: err, sorry, missed the first line of the comment :). 5-7 Seconds is a little long, but I hope it is clear that the bulk of your issue is server side. Try completely removing your TreeTable, and see if that reduces the time further. If so, rendering is really your issue, and if not, I will need more info about your env to provide any other useful suggestions.

mgoerdes
28 Jul 2009, 4:45 AM
Did anyone of you already tried the new GWT RPC implementation in GWT 2.0?

http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/631b8c3177930913/c2c9e724568542f4?lnk=gst&q=performance+rpc#c2c9e724568542f4

I made a small test an saw some nice improvements.

livinglegends
28 Jul 2009, 4:56 AM
Okay. So this means that the server is producing 7-8 seconds of delay - that is your problem. That leaves 5-7 seconds of delay in Hosted mode.

In hosted as well as web mode server side code is taking 5-7 seconds.


Again, please verify using Web mode - running in Hosted Mode givens nice benchmarks since you can call System.out.println, but there is extra overhead as well. I would be very surprised if your code took longer than 10 seconds (8 on server + 2 on client) once you ran in web mode.

I have run in Web mode and check elapsed time to return List back to client. It is taking 12-14 seconds. That means total time is "Time taken by server to retrieve data+Time taken to get back List" which is "7+14" = 21 seconds.

livinglegends
28 Jul 2009, 11:00 PM
Did anyone of you already tried the new GWT RPC implementation in GWT 2.0?

http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/631b8c3177930913/c2c9e724568542f4?lnk=gst&q=performance+rpc#c2c9e724568542f4

I made a small test an saw some nice improvements.

Thanks for your gr8 suggestion.
I found GWT 1.7 latest version. So, GWT 2.0 means version on GWT-EXT or anything else?
Can you share that code or code snippet for me? Or can you send me the link of GWT 2.0?

mgoerdes
29 Jul 2009, 12:34 AM
No, GWT 2.0 means the current trunk of GWT. Its not part of GXT.

http://code.google.com/intl/de-DE/webtoolkit/makinggwtbetter.html#workingoncode

livinglegends
29 Jul 2009, 12:37 AM
so does this feature "deRPC" available in GWT 1.7?
if not how to get it?

mgoerdes
29 Jul 2009, 12:42 AM
No, its not part of 1.7, its part of the 2.0 trunk, committed in the last 2 weeks. >ou only get it by compiling the source as described here:

http://code.google.com/intl/de-DE/webtoolkit/makinggwtbetter.html#workingoncode

livinglegends
29 Jul 2009, 12:45 AM
but I am using GWT 1.7 in project. So, how can I then integrate it in my existing project with GWT 1.7?

mgoerdes
29 Jul 2009, 12:52 AM
I don't think, that this is possible.

livinglegends
29 Jul 2009, 12:55 AM
So how one can get benefit of improved RPC? is there any way or will it be available in next release of GWT?

livinglegends
30 Jul 2009, 3:26 AM
I don't think, that this is possible.

Can I improve performance of client-server communication using JSON instead of RPC?
How to convert Object to JSON and JSON to Object?
Is there any API available which we can use at client side(GWT side) to convert to Object to JSON and vice-versa?

livinglegends
25 Aug 2009, 11:02 PM
I don't think, that this is possible.

Hi,

How one can get benefit of improved RPC? is there any way or will it be available in next release of GWT?