This discussion is archived
3 Replies Latest reply: Feb 24, 2011 8:19 AM by jtahlborn RSS

RMI vs Socket performance

832415 Newbie
Currently Being Moderated
Hello!

How much slower is the newest version of RMI compared to Java Sockets?

Thank you
  • 1. Re: RMI vs Socket performance
    EJP Guru
    Currently Being Moderated
    You are comparing apples and oranges. By the time you add in all the extra features that RMI provides you are going to end up with something pretty similar to RMI's performance. Most RMI overhead is either DNS overhead, which you are also going to get with Sockets, or serialization overhead, which you may or may not also get with Sockets depending on how you plan to use them. Absent that information the question is really pretty meaningless.
  • 2. Re: RMI vs Socket performance
    802316 Pro
    Currently Being Moderated
    By the time you add in all the extra features that RMI provides you are going to end up with something pretty
    ... buggy and very hard to test.

    If you need a good portion of the features provided by RMI, you are better off using the builtin/tested RMI.

    Using raw sockets is a good idea if a) there is no support available for the protocol you need to use b) your specific needs are very simple and can be easily tested end to end very thoughly.
    serialization overhead, which you may or may not also get with Sockets depending on how you plan to use them
    You can almost replace the builtin serailization with your own if you really need to. Create a wrapper object (or extend a top level one) which serializes everything your own way. This way you are only using the builtin Java Serialization to bootstrap yours. This only makes a difference for large objects. If you want maximum efficiency for small objects, you will need your own serialization or one of the many open sources ones like hessian or protobuffers.

    You should test your usecase to see if RMI is fast enough. If it is, you are likely to be best off sticking with it.
  • 3. Re: RMI vs Socket performance
    jtahlborn Expert
    Currently Being Moderated
    Peter Lawrey wrote:
    By the time you add in all the extra features that RMI provides you are going to end up with something pretty
    ... buggy and very hard to test.
    this!!! many times over.
    If you need a good portion of the features provided by RMI, you are better off using the builtin/tested RMI.
    heed these words.
    serialization overhead, which you may or may not also get with Sockets depending on how you plan to use them
    You can almost replace the builtin serailization with your own if you really need to. Create a wrapper object (or extend a top level one) which serializes everything your own way. This way you are only using the builtin Java Serialization to bootstrap yours. This only makes a difference for large objects. If you want maximum efficiency for small objects, you will need your own serialization or one of the many open sources ones like hessian or protobuffers.
    You don't even really need to create a wrapper object. Externalizable gives you pretty much the same features.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points