Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

RMI round trip to create the object

Thread view: 
yosi.kal@gmail.com - 23 Apr 2007 09:58 GMT
Hi,

I am writing a Java client server application in which the clients
resides in a long physical distance from the server. For example,
clients can be in India while server is San Jose. There is a secured
TCP connection between the clients and the server and the connection
between clients and server is done using RMI.
The thing is I noticed a performance drop due to the fact that RMI is
doing two round trips in order to execute single method: one round
trip is to create the object (Naming.lookup) and then another one is
to invoke the method on the object. Each round trip takes an overhead
of 1-2 seconds just to get from the client to the server. Logically, I
don't have any sequential calls on the same object so its actually a
performance cost I pay for each method invocation (every time user is
opening a window or something like that).

Is there any way I can combine the two round trips into one in order
to save one round trip cost?

Thanks
Robert Klemme - 23 Apr 2007 10:03 GMT
> I am writing a Java client server application in which the clients
> resides in a long physical distance from the server. For example,
[quoted text clipped - 12 lines]
> Is there any way I can combine the two round trips into one in order
> to save one round trip cost?

Probably not - other than caching object references around in the client
so the lookup is a local lookup.

On a more general scale I'd say your design is probably not optimal: RMI
(as CORBA and like protocols) give you remote access to individual
methods.  Having said that, they work best with fast network
connections.  In your case you probably need to redesign to a) either
choose another protocol or b) provide objects as interface that have
less overhead, i.e. methods that do more in one invocation.

Kind regards

    robert
yosi.kal@gmail.com - 23 Apr 2007 10:19 GMT
Hi Robert,

Regarding caching the connections on the clients, do you know if there
is an overhead in the server for each client that creates the object
on the server? What I mean is, lets say that I will create the object
on the client, keep it alive and use it whenever I need. Does the
server allocates some memory or any other resources for each object
created?

Thanks
Robert Klemme - 23 Apr 2007 14:27 GMT
> Regarding caching the connections on the clients, do you know if there
> is an overhead in the server for each client that creates the object
> on the server? What I mean is, lets say that I will create the object
> on the client, keep it alive and use it whenever I need. Does the
> server allocates some memory or any other resources for each object
> created?

I guess the server will somehow count number of client objects (or hold
a reference per connection), in order to make sure the server object is
not collected before all client stubs are.

    robert
Esmond Pitt - 24 Apr 2007 08:14 GMT
> Regarding caching the connections on the clients

RMI does TCP connection pooling. The client reuses idle TCP connections
that are up to 15 seconds old. Idle connections older than that are closed.

> do you know if there
> is an overhead in the server for each client that creates the object
> on the server? What I mean is, lets say that I will create the object
> on the client, keep it alive and use it whenever I need. Does the
> server allocates some memory or any other resources for each object
> created?

I don't know exactly what 'object[s] created' you're talking about here.

A thread is allocated at the server for each open TCP connection, which
exits when the connection is closed as per above, or after a maximum of
2 hours. All that is tunable.
Esmond Pitt - 24 Apr 2007 08:10 GMT
> Is there any way I can combine the two round trips into one in order
> to save one round trip cost?

You only need to do the Naming.lookup() once!. Then you can keep calling
methods on the returned stub until you get a failure. At that point you
should redo the lookup.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.