NATS pub-sub, publish rate affected by the number of subcribers #5641
Replies: 1 comment
-
Well, nothing comes for free. With just 1 publisher and 1 subscriber, after receiving a message from the publisher the server just needs to send it down 1 client connection (one TCP socket) and then it can use it's resources (CPU) to a process the next incoming message. As you increase the fan out, the server has to use its resources to make more copies of the message and send them down more TCP client connections. If you have enough network bandwidth and sufficient CPU available you may be able to go from 1 subscriber to 2 subscribers without much of a slow down on the publish rate, but as you add subscribers sooner or later you are going to see the ingress rate go down. Another thing that can affect publishing throughput as you add subscribers is if one of those subscribers can not keep up with the message rate and turns into a 'slow consumer' (this can for example increase latency for the publisher) see #5394 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello I have a question about pubsub.
I was testing the pubsub rate with NodeJS and later I found the number of subscribers affect publish performance.
I wonder if it is actually how it is or if I miss anything in my testing? I also found the nats bench result when testing 1:N throughput test the publish rate is also lower than 1:1 here https://docs.nats.io/using-nats/nats-tools/nats_cli/natsbench#run-a-1-n-throughput-test.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions