DD.
DD.

Reputation: 21991

Messaging latency in java (with zeromq)

I just ran the zeroMQ hello world example and timed the request-response latency. It averaged about 0.1ms running using the IPC protocol. This sounds quite slow to me....Does this sound about right?

        long start=System.nanoTime();
        socket.send(request, 0);
        //  Get the reply.
        byte[] reply = socket.recv(0);
        System.out.println((System.nanoTime()-start)/1000000.0);

Upvotes: 1

Views: 853

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533570

I assume your average had a sample of more than one? I would run the test for at least 2-10 seconds before taking an average. The average latency in the same process/thread may be misleading.

I would create a second process which echo everything it gets if you are not doing this already. (And divide the latency in two unless you want the RTT latency)

Plain Sockets can get a RTT latency of 20 micro-seconds on a typical multi-core box and I would expect IPC to be faster. On a fast PC you can get a typical RTT latency of 9 micro-second using sockets.

If you want latency much lower than this, I would consider doing everything in one process or one thread if you can, in which case the cost of a method call is around 10 ns (if its not inlined ;)

Upvotes: 3

Related Questions