Skip to content
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

default DRY as to the cocurrent handlers of the cosumer #153

Closed
chaosue opened this issue Aug 13, 2015 · 2 comments
Closed

default DRY as to the cocurrent handlers of the cosumer #153

chaosue opened this issue Aug 13, 2015 · 2 comments

Comments

@chaosue
Copy link

chaosue commented Aug 13, 2015

It seems that the default RDY for the cosumer connection is always 1, in spite of the "cocurrency" that set by the "AddConcurrentHandlers" method, consequently, the messages can only be sent to one handler goroutine at the same time, other goroutines has to wait, until the "FIN" is sent for the read message.

To resolve this situation, it has to manually call the "ChangeMaxInFlight" method, then all of the handler goroutines can receive messages (if they're in the queue ) at the same time.

@jehiah
Copy link
Member

jehiah commented Aug 13, 2015

@chaosue You are correct. MaxInFlight (which controls the RDY count each individual connection to a nsqd instance gets and the total number of messages you can have outstanding at any point in time) is independent of the concurrency control.

This is by design.

Since nsqd operates on a push basis (nsqd pushes messages to clients), MaxInFlight allows you to oversubscribe to eliminate latency. If for example you had MaxInFlight=2 but concurrency=1, while processing 1 message nsqd could send the "next" message over the wire so it's ready to be processed instantly after the first one is completed. Without oversubscribing you would have to wait a round trip time between client finishing, sending the response and then getting the next message. This would undesirably limiting throughput in some situations, especially high latency ones.

@jehiah
Copy link
Member

jehiah commented Aug 13, 2015

I'm going to close this issue, but if you have more questions please ask.

@jehiah jehiah closed this as completed Aug 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants