novnc / websockify

Websockify is a WebSocket to TCP proxy/bridge. This allows a browser to connect to any application/server/service.
GNU Lesser General Public License v3.0
3.95k stars 781 forks source link

Connection pooling #568

Closed davidtaddei closed 10 months ago

davidtaddei commented 10 months ago

Great work on this project, I do have a question regarding scaling users however.

Currently each client connected via websockets has a new TCP connection established to the target machine, even if they are initiated from the same source and using the same credentials etc. As such the bandwidth consumed between websockify and a target machine grows as the number of connected websocket clients grows.

Is it possible to connection pool based on the target machine and allow traffic flowing from TCP -> Websockets to be replicated at the websocket layer instead of being carried through concurrent TCP connections? Even a simple strategy similar to replicated load balancing would be helpful where all connected websocket clients want to receive the same data.

CendioOssman commented 10 months ago

I'm afraid that is not possible. websockify is a completely transparent proxy, meaning that it has no idea what the traffic it proxies actually means. So it cannot determine things like which data can be shared between multiple clients.

I would suggest building something custom that is more aware of the protocol you wish to proxy. Some components from websockify might still be interesting for you as a base, though. E.g. the WebSocket socket wrapper class.