-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with polling #2078
Comments
I've found the problem / solution for this. Instead using
Now Although the issue is solved I'll left this open to increase visibility. If you don't agree with this - you can close it. |
Since the problem is solved I'll close here, since we have already a lot of open issues to deal with. |
I'm using clrzmq4, but since it is only a wrapper for libzmq I believe that I can get help here.
What I'm trying to accomplish is to implement reading a message from one of two sockets, wherever it arrives first. As far as I understand polling (
zmq_poll
) is the right thing to do (as demonstrated in mspoller in guide). Here I'll provide small pseudo-code snippet:As you can see it is actually the same exact implementation as in mspoller in guide.
In my case
receiver2
(PAIR socket) should receive a large number of messages. In fact I've created a test in which number of messages sent to it is always greater than the number of messages it is capable to receive (at least in demonstrated implementation).I've run the test for 2 seconds, and I was very surprised with results:
receiver2
: 180 (by "sent" I mean that they are handed out to another PAIR socket not shown in the previous snippet);receiver2
: 21 ??? Only 21 messages in 2 seconds??? 10 messages per second???Then I've tried to play with different
timeout
values and I've found out that it significantly influences the number of messages received. Duration (2 seconds) and number of messages sent (180) remain the same. The results are:timeout
value of 200 milliseconds - number of messages received drops to 10 (5 per second);timeout
value of 10 milliseconds - number of messages received rises to 120 (60 per second).The results are telling me that polling simply does not work. If polling were working properly, as far as I understand the mechanism,
timeout
should not have any influence in this scenario. No matter if we set timeout to 1 hour or 5 milliseconds - since there are always messages to receive there's nothing to wait for, so the loop should work with the same speed.My another big concern is the fact that even with very small
timeout
valuereceiver2
is not capable to receive all 180 messages. I'm struggling here to accomplish receiving rate of 100 messages per second, although I've selected ZeroMQ which should be very fast (benchmarks are mentioning numbers as 6 million messages per second).So my question is obvious: am I doing something wrong here? Is there a better way to implement polling?
Thanks
The text was updated successfully, but these errors were encountered: