简体   繁体   English

Java中的消息传递延迟(使用zeromq)

[英]Messaging latency in java (with zeromq)

I just ran the zeroMQ hello world example and timed the request-response latency. 我刚刚运行了zeroMQ hello world示例并计算了请求 - 响应延迟。 It averaged about 0.1ms running using the IPC protocol. 使用IPC协议平均运行约0.1毫秒。 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);

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. 在取平均值之前,我会进行至少2-10秒的测试。 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) (除非你想要RTT延迟,否则将延迟分成两部分)

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. 普通套接字在典型的多核盒上可以获得20微秒的RTT延迟,我希望IPC更快。 On a fast PC you can get a typical RTT latency of 9 micro-second using sockets. 在快速PC上,您可以使用套接字获得9微秒的典型RTT延迟。

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 ;) 如果您希望延迟远低于此,我会考虑在一个进程或一个线程中执行所有操作,如果可以的话,在这种情况下,方法调用的成本大约为10 ns(如果它没有内联;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM