How to manage graphql-ws client at the gateway for different users #194
Replies: 2 comments 7 replies
-
I converted this to a Discussion - it is better fitted here. Lets jump right in... I'd start by saying, be very careful with creating too many WS connections, since each WS connection creates its own TCP connection which can be quite wasteful. However, the maximum connections is not as for SSE (6-8 depending on the browser), you can have (I think) around 200 for Chrome. But, I guess the snippet above is on the server - so the limits dont quite apply (or are configurable at least). WebSockets are quite resilient so using 1 WS for multiple downstream clients should be just fine. Nevertheless, wouldnt you agree that creating separate upstream connections for each browser is an overkill? You might end up consuming much more resources than necessary when lots of clients connect. 100 clients -> 100 tunnel connections. For scaling, I'd recommend simple load balancers and services on-demand. A single server can handle quite an amount of WS connections without too many issues - especially if you're using something very efficient, like µWebSockets.js. |
Beta Was this translation helpful? Give feedback.
-
Hey! I have a related question: As I understand, upstream subscription will not get terminated in that case? How should we address that? Extend the protocol to send custom |
Beta Was this translation helpful? Give feedback.
-
In my architecture, each client (browser) connects to the gateway. The gateway then connects with the appropriate upstream graphql subscription service, creating a separate upstream websocket connection for each downstream connection using the code below
What is recommended way to manage connections at scale: Can we use the same websocket connection for multiple downstream client connection? I think not. I have added more details in this issue. Would love to hear your thoughts @enisdenjo.
Beta Was this translation helpful? Give feedback.
All reactions