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

nsqd: better diskqueue error backpressure #437

Merged
merged 5 commits into from
Aug 18, 2014

Conversation

mreiferson
Copy link
Member

This is a continuation of the work done in #422, returning the error directly to the PUB in question, thus providing a better backpressure mechanism (vs. asynchronous as of #422).

Simultaneously, it happens to significantly improve performance (41% on PUB benchmark) by removing the topic's router() goroutine (see first commit msg for details, but basically router() was effectively serializing PUB requests):

$ GOMAXPROCS=4 ./bench.sh
PUB: 2014/08/15 10:17:37 duration: 996.190589ms - 191.464mb/s - 1003823.978ops/s - 0.996us/op

select {
case c.memoryMsgChan <- m:
default:
// TODO: re-use this buffer
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to figure out how to re-use this buffer before we merge...

this change accomplishes a few things...

1. goroutines calling topic.Put*() via HTTP or TCP
   will now be able to directly detect failed diskqueue writes,
   giving the type of feedback you need to retry, without
   any asynchronous interaction.

2. related to (1), goroutines (and thus clients) will experience
   *direct* backpressure when messages are written to disk.

3. removes an extra goroutine per topic and an extra channel
   send/receive per PUB.  the aggregate effect on benchmarks
   is significant because this setup has far better concurrency
   characteristics (41% faster):

    $ GOMAXPROCS=4 ./bench.sh
    PUB: 2014/08/15 10:17:37 duration: 996.190589ms - 191.464mb/s - 1003823.978ops/s - 0.996us/op
@mreiferson
Copy link
Member Author

RFR @jehiah

@mreiferson mreiferson added bug and removed feature labels Aug 16, 2014
jehiah added a commit that referenced this pull request Aug 18, 2014
nsqd: better diskqueue error backpressure
@jehiah jehiah merged commit 8e1f6b2 into nsqio:master Aug 18, 2014
@mreiferson mreiferson deleted the direct_error_feedback_437 branch August 18, 2014 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants