Git Product home page Git Product logo

Comments (3)

jehiah avatar jehiah commented on June 19, 2024

Hey @twmb I'm happy to share a little bit about our thinking. While you could take that approach, we felt it important for go-nsq to enable high volume message processing. At higher volumes the churn of per-message goroutines becomes a significant overhead and bottleneck so we avoid that implementation approach both on the go-nsq library and on nsqd itself.

If a client wants per-message goroutines for lower volume handling it's always possible to add that (I included one possible approach below), but it wouldn't be possible to undo per-message goroutines if go-nsq added that.

There is also a limiting concurrency factor in how you configure max-inflight which sets the max possible messages you could see at a time. If you want effectively individually goroutined message handling you can set the number of concurrent handlers to match your max-inflight setting (since you'll never need more goroutines than that). It's been my personal experience that having strong controls on concurrency is helpful in a distributed system so you can appropriately limit capacity to downstream databases.

consumer.AddHandler(nsq.HandlerFunc(func(m *Message) error {
    m.DisableAutoResponse()
    go yourHandler(m)
    return nil
}))

from go-nsq.

twmb avatar twmb commented on June 19, 2024

I didn't realize that a variable number of goroutines had worse performance than having a constant amount of goroutines all polling from a channel. I'm all for performance. ๐Ÿ‘

from go-nsq.

mreiferson avatar mreiferson commented on June 19, 2024

@jehiah pretty much summed it up, I'm gonna close this, but thanks for the question @twmb!

from go-nsq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.