Closed smjure closed 1 year ago
WithProcessors
configures the number of goroutines processing the messages coming from the server. Note that you don't know what a message contains (trades or quotes or both) until you actually parse it! So no, it wouldn't make sense to have separate configurations for the message types.
Personally I found little to no performance gain by increasing the processor count, as long as your message handlers are fast enough. The message unmarshaler is actually pretty fast, the benchmark runs on my machine ~1300 ns! So if you have performance issues, it's most likely coming from your handler(s), and simply parallelising may or may not solve the problem.
Say we have a stock client streaming
trades
andquotes
, i.e.I wonder what happens if you set
stream.WithProcessors(1)
? Does all messages fromtrades
andquotes
are processed via single goroutine/CPU? And what happens if you set e.g.stream.WithProcessors(4)
in this case? Would it be reasonable to do something like:In this way if
nbProcessors=1
, it could be ensured same fly-in time fortrades
andquotes
as it comes to the server. This is also performance wise better as we can separate scripts fortrades
andquotes
. Perhaps I am wrong? 🙏🏻