koding / websocketproxy

WebSocket reverse proxy handler for Go
http://godoc.org/github.com/koding/websocketproxy
MIT License
427 stars 120 forks source link

Multiple backends #7

Closed faddat closed 7 years ago

faddat commented 7 years ago

Hi, can I use this to load balance a websockets connection? Suppose I've got:

192.168.0.2:8090 (ws server 1 int addr) 192.168.0.3:8090 (ws server 2 int addr) 192.168.0.4:8090 (ws server 3 int addr) 192.168.0.5:8090 (ws server 4 int addr)

Can I assign them all as back ends to websocketproxy or is websocketproxy currently limited to just one back end?

cihangir commented 7 years ago

HI @faddat

websocketproxy currently limited to just one back end?

yes it only supports one backend, but we would love to see backward compatible contributions for supporting multiple backends

faddat commented 7 years ago

I'd happily contribute, sometime in the next few months, but have a question: the "right" way to implement multiple backends would be:

Set it up so that sessions persist between one of the backs and the user via the proxy for some fixed period of time, correct? Incorrect?

cihangir commented 7 years ago

Thanks for the comment @faddat

Due to nature of the WS, all connections should be sticky from the beginning, one connection should stay with one backend as long as both sides are open. To be able to distribute load evenly we might need to keep track of connection counts among backends.