Comments (3)
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.
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.
@jehiah pretty much summed it up, I'm gonna close this, but thanks for the question @twmb!
from go-nsq.
Related Issues (20)
- panic: send closed channel - incomingMessages HOT 1
- feat: NSQ cluster or public network message synchronization
- v1.2.1 use DeferredPublish publish delay message,delay invalidation HOT 4
- SIngleton Producer HOT 2
- Can you tag v1.0.9 HOT 1
- How to use Command? HOT 1
- Support NSQ in ArgoLabs Dataflow HOT 1
- the tag of v1.0.8, and the file of doc.go line 65, the value name p is error, in fact, it is producer. HOT 2
- Disconnects seem to be quite ungraceful HOT 2
- "go test" fails with "connection refused" HOT 2
- Client doesn't know it's disconnected HOT 2
- Panic in producer's router HOT 2
- Conn cannot execute multiple subscribe commands HOT 1
- error connecting to nsqd - dial tcp 127.0.0.1:4150: connect: connection refused๏ผ HOT 1
- An Example of multit-hreaded nsq consuming messages HOT 1
- producer: HTTP response to IDENTIFY causes memory allocation of over 1GB HOT 2
- how to clear data in nsq HOT 1
- MaxAttempts Callback HOT 1
- *: context.Context and timeouts
- How can I limit the queue size?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-nsq.