zeromq performance test. What's the accurate latency?

左心房为你撑大大i 提交于 2019-12-07 07:17:25
Willy Pell

I'm having the same problem: ZeroMQ - pub / sub latency

I ran wireshark on my example code which publishes a zeromq message every second. Here is the output of wireshark:

145  10.900249     10.0.1.6 -> 10.0.1.6     TCP 89 5557→51723 [PSH, ACK] Seq=158 Ack=95 Win=408192 Len=33 TSval=502262367 TSecr=502261368
146  10.900294     10.0.1.6 -> 10.0.1.6     TCP 56 51723→5557 [ACK] Seq=95 Ack=191 Win=408096 Len=0 TSval=502262367 TSecr=502262367
147  11.901993     10.0.1.6 -> 10.0.1.6     TCP 89 5557→51723 [PSH, ACK] Seq=191 Ack=95 Win=408192 Len=33 TSval=502263367 TSecr=502262367
148  11.902041     10.0.1.6 -> 10.0.1.6     TCP 56 51723→5557 [ACK] Seq=95 Ack=224 Win=408064 Len=0 TSval=502263367 TSecr=502263367

As you can see it's taking about 45 microseconds to send and acknowledge each message. At first I thought that the connection was getting re-established on each message but that's not it. So I turned my attention to the receiver...

while(true)
    if(subscriver.recv(&message, ZMQ_NOBLOCK)) {
        // print time
    }
}

By adding the ZMQ_NOBLOCK and polling in a hard while loop I got the time down to 100us. That still seems large and it comes at the price of spiking one core. But I do feel like I understand the problem slightly better. Any insight would be appreciated.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!