14 Replies Latest reply: Apr 13, 2012 4:10 AM by 925521 RSS

    RMI Remote Performance

    925521
      I have made 2 Java applications: a server and a client. I have already acomplished to put them connected with RMI and tried 2 different scenarios.

      First scenario: on my home network i have a desktop with the server application and another desktop with the client application. Both are running and passng data, despite the time needed to pass this data is higher than using a desktop and localhost to run both the server and the client.

      Second scenario: i have installed the application server in a desktop in my home and a client, far away (like 10km +/-). I wait like half a minute or, sometimes a minute, to pass data between the server and the client.

      Is this second scenario normal? How can i improve my RMI performance?
        • 1. Re: RMI Remote Performance
          DrClap
          If you're sending 20 bytes, then I would say that's not normal. If you're sending 20 megabytes, I would say it's normal. You failed to mention anything about your data; there's no such thing as a data-free performance analysis.
          • 2. Re: RMI Remote Performance
            EJP
            And distance is irrelevant. What matters is the bandwidth and the latency of the intervening network.
            • 3. Re: RMI Remote Performance
              925521
              Well, i know distance doesn´t mean nothing.

              Well, first i bind the client to the server rmi registry, doing this
              1) Util._request = (IRMIServer) LocateRegistry.getRegistry(Util._hostIP, Integer.parseInt(Util._port)).lookup(Util._addressBind);

              Then the client calls a login method in this registry (that exist on the server) and the result is a String (like 16 charaters to represent a hash), and sends the client reference to the server be able to callback.
              2) String hashAuth = proxy.loginProxy(Util.myIP, "proxy", (IRMIClient)Util._client);

              This call takes a long time. I mean, the first call (1) takes 21427 milliseconds or 21 seconds. And the login call takes like 21141 milliseconds or 21 seconds too.

              What could be my problem?
              • 4. Re: RMI Remote Performance
                EJP
                Well, i know distance doesn´t mean nothing.
                So it means nothing to tell us the distance is 10km.
                Well, first i bind the client to the server rmi registry, doing this
                1) Util._request = (IRMIServer) LocateRegistry.getRegistry(Util._hostIP, Integer.parseInt(Util._port)).lookup(Util._addressBind);
                That's not a bind, that's a lookup.
                Then the client calls a login method in this registry (that exist on the server) and the result is a String (like 16 charaters to represent a hash), and sends the client reference to the server be able to callback.
                2) String hashAuth = proxy.loginProxy(Util.myIP, "proxy", (IRMIClient)Util._client);
                Where did '_proxy' come from?
                This call takes a long time. I mean, the first call (1) takes 21427 milliseconds or 21 seconds. And the login call takes like 21141 milliseconds or 21 seconds too.

                What could be my problem?
                Network performance problems of this magnitude are usually DNS problems. Check to see how long it takes to ping the server from the client, and to do a reverse DNS lookup of the server IP address.
                • 5. Re: RMI Remote Performance
                  925521
                  EJP wrote:
                  Well, i know distance doesn´t mean nothing.
                  So it means nothing to tell us the distance is 10km.
                  Yes, i know, it was just to give an example.
                  Well, first i bind the client to the server rmi registry, doing this
                  1) Util._request = (IRMIServer) LocateRegistry.getRegistry(Util._hostIP, Integer.parseInt(Util._port)).lookup(Util._addressBind);
                  That's not a bind, that's a lookup.
                  Yes, that´s a lookup. I wrote bad, but i wanted to say lookup.
                  Then the client calls a login method in this registry (that exist on the server) and the result is a String (like 16 charaters to represent a hash), and sends the client reference to the server be able to callback.
                  2) String hashAuth = proxy.loginProxy(Util.myIP, "proxy", (IRMIClient)Util._client);
                  Where did '_proxy' come from?
                  Ok, it´s the same as doing "String hashAuth = _request.loginProxy(Util._myIP, "proxy", (IRMIClient)Util._client);", since request is a RMIServer interface object of the methods that exist on the server registry. But proxy is a request handler. Well, i kinda tried to do a Proxy Pattern. I don´t think the higher time are from this coding line. At least i hope so...
                  This call takes a long time. I mean, the first call (1) takes 21427 milliseconds or 21 seconds. And the login call takes like 21141 milliseconds or 21 seconds too.

                  What could be my problem?
                  Network performance problems of this magnitude are usually DNS problems. Check to see how long it takes to ping the server from the client, and to do a reverse DNS lookup of the server IP address.
                  I have did the ping to the server, with the following results:
                  -time between 9 ms and 10 ms; TTL=258; minimum=9ms; maximum=10ms; average=9ms.

                  I have done a reverse DNS lookup on the same ip and the result was:
                  -454 ms.

                  I though already that it should be two things: or the time spent by the server doing calculations (i don´t really think so, because it is just a MD5Encoding on a string, insert in database and returns to the client the hash string); or the amout of data returned (but it´s just a string...). I don´t wanna think how much time it will spend sending some real data...

                  Edited by: 922518 on 23/Mar/2012 3:59
                  • 6. Re: RMI Remote Performance
                    925521
                    Can anyone help me on this one?
                    • 7. Re: RMI Remote Performance
                      EJP
                      Ok, a few more questions:

                      1. How long does the lookup take?
                      2. Please print the result of the lookup, I.e. toString() of the stub.
                      3. How long does it take to ping and DNS-lookup the IP address printed in (2)?
                      4. Is the IP address in (2) the same as the IP address you used for the lookup?
                      • 8. Re: RMI Remote Performance
                        925521
                        EJP wrote:
                        Ok, a few more questions:

                        1. How long does the lookup take?
                        Registry Lookup Time: 22734 miliseconds.
                        2. Please print the result of the lookup, I.e. toString() of the stub.
                        STUB PRINT: Proxy[IRMIServer,RemoteObjectInvocationHandler[UnicastRef [liveRef: [endpoint:[193.136.205.29:53160](remote),objID:[52660a2c:1367e055aa3:-7fff, 7639948144137917158]]]]]
                        3. How long does it take to ping and DNS-lookup the IP address printed in (2)?
                        Ping: time      8055 ms
                        Reverse DNS lookup time: Total elapsed query time: 1,367 ms
                        4. Is the IP address in (2) the same as the IP address you used for the lookup?
                        I used the ip: '193.136.205.29' for lookup and the ip printed is the same: '193.136.205.29'.

                        Something like that...I hope it helped. The computer i´m testing the remote communication with the server is in a local network at my home.
                        • 9. Re: RMI Remote Performance
                          EJP
                          Well a Registry lookup is little more than HashMap.get() internally. I would say this is all DNS delays. Can you sniff the network?
                          • 10. Re: RMI Remote Performance
                            925521
                            Wil Wireshark do the job?
                            • 11. Re: RMI Remote Performance
                              EJP
                              Yep
                              • 12. Re: RMI Remote Performance
                                925521
                                For some reason, i´m trying to work with wireshark. I can´t sniff my own network. I start doing it, but i don´t receive packets :S
                                • 13. Re: RMI Remote Performance
                                  EJP
                                  Wireshark can only see what's on the wire. If you're running client and server inside the same host the packets don't get to the wire, they are short-circuited. If they are different hosts, try capturing on a different adapter.
                                  • 14. Re: RMI Remote Performance
                                    925521
                                    Yes i know. I wanted only to test and see some packets there but i don´t see none of them. And i´m capturing what´s in the my LAN (at least i think so). When i can sniff something i´ll post again. Thank you very much for the help here ;)