RMI round trip to create the object

Discussion in 'Java' started by yosi.kal@gmail.com, Apr 23, 2007.

  1. Guest

    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
     
    , Apr 23, 2007
    #1
    1. Advertising

  2. On 23.04.2007 10:58, wrote:
    > 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
     
    Robert Klemme, Apr 23, 2007
    #2
    1. Advertising

  3. Guest

    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
     
    , Apr 23, 2007
    #3
  4. On 23.04.2007 11:19, wrote:
    > 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
     
    Robert Klemme, Apr 23, 2007
    #4
  5. Esmond Pitt Guest

    wrote:

    > 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.
     
    Esmond Pitt, Apr 24, 2007
    #5
  6. Esmond Pitt Guest

    wrote:

    > 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.
     
    Esmond Pitt, Apr 24, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Row
    Replies:
    1
    Views:
    703
    vMike
    Nov 26, 2003
  2. =?Utf-8?B?WWFuaXI=?=

    Sort table without round trip

    =?Utf-8?B?WWFuaXI=?=, Apr 6, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    759
    Steve Drake
    Apr 6, 2004
  3. Rathtap
    Replies:
    2
    Views:
    514
    Janaka
    Aug 24, 2004
  4. Replies:
    8
    Views:
    460
    =?Utf-8?B?TWF0SGVydGVs?=
    Oct 8, 2005
  5. =?Utf-8?B?TGFycnk=?=

    Disable web page controls during postback round-trip

    =?Utf-8?B?TGFycnk=?=, Mar 9, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    6,246
    Adrian Parker
    Mar 9, 2006
Loading...

Share This Page