RMI round trip to create the object

Y

yosi.kal

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
 
R

Robert Klemme

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?

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
 
Y

yosi.kal

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
 
R

Robert Klemme

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
 
E

Esmond Pitt

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.
 
E

Esmond Pitt

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 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top