Search code examples
javaprofilingrmi

Java RMI: statistics for object stubs


I'd like to profile network overhead of my RMI-based application. For instance, I'd be interesting to know how many bytes a stub transferred over the network, or how many method calls were done through it. I can't find anything in the RMI API to hook into, though. Is this possible at all?


Solution

  • I am not particularly fond of RMI and found JSon-based, Thrift and even XML-RPC easier to work with. However, sometimes we don't have a choice.

    There is a microbenchmark suite for RMI, as well as object serialization, in the "test" tree of the jdk7/jdk repository, see:

    jdk/test/java/rmi/reliability/benchmark
    

    The script:

    jdk/test/java/rmi/reliability/scripts/create_benchmark_jars.ksh
    

    shows how to create two JAR files which is used in the benchmarking. You can pass command-line parameters to each each instance for specific settings such repetitions per run, etc. (One instance of the jar will run as the client and the other as the server, which is also configured from a command line parameter.)

    I haven't played much with this myself - usually trusting existing benchmarks, for example:

    http://daniel.gredler.net/2008/01/07/java-remoting-protocol-benchmarks

    ...or using tools such as (I haven't looked much at the last two):

    JMeter (http://jmeter.apache.org/), Soap-stone (http://soap-stone.sourceforge.net/) or JVM-serialisers (https://github.com/eishay/jvm-serializers/wiki/)