Specializing Websocket connections between "read-only" (subscribe) vS "write-only" (publish) #2760
-
Quick question just to be sure because I couldn't find any explicit information about this in the official docs ... (sorry if this has been answered elsewhere - feel free to point out any links) In regard to best programming practices for a single client connecting to nats-servers using websocket: Would it make sense to keep 2 connections up for this client:
I'm simply exploring whether the nats-server optimizes the connections for these two cases to make the most out of them. I'm aware of the following facts:
Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Similar to TCP, websockets can handle bi-directional activity and we recommend folks to start with one connection. Since it is a single connection there could be head of line blocking, mostly from the system to your app (subscriptions). So if you have multiple subscriptions and might encounter latency sensitive processing that could be affected by head of line blocking, then move subscriptions across multiple connections. |
Beta Was this translation helpful? Give feedback.
Similar to TCP, websockets can handle bi-directional activity and we recommend folks to start with one connection. Since it is a single connection there could be head of line blocking, mostly from the system to your app (subscriptions). So if you have multiple subscriptions and might encounter latency sensitive processing that could be affected by head of line blocking, then move subscriptions across multiple connections.