Re:WebSocket proxy support added to nginx trunk
by jabr on Monday February 18, 2013 @10:18PM
(#5242390)
WebSockets are persistent connections, not a state-management trick spanning multiple connections/requests. The only time nginx is involved in "routing" the socket is on the initial connection. Once established, nginx is simply relaying data over an active, persistent TCP/unix sockets.
For the initial connection, you can use any of nginx's normal proxy load balancing options (ip_hash, least_conn, etc).
Re:WebSocket proxy support added to nginx trunk
by mattyb on Monday February 18, 2013 @08:06PM
(#5241956)
HAProxy can, reportedly, load balance WebSocket connections:
http://blog.exceliance.fr/2012/11/07/websockets-load-balanci...
dotCloud's Hipache also looks like it was basically written to solve this problem:
Re:WebSocket proxy support added to nginx trunk
by runesoerensen on Monday February 18, 2013 @06:30PM
(#5241556)
I'd expect the ip_hash directive to work as usual http://wiki.nginx.org/HttpUpstreamModule#ip_hash although it's not exactly sticky sessions. There's a separate module for that https://github.com/michaelneale/nginx-sticky-module
Normally I think it's best for HTTP backends to be stateless, but WebSockets open up interesting possibilities for RPC solutions like NowJS (https://github.com/Flotype/now), dnode (https://github.com/substack/dnode), and others (https://github.com/kriskowal/q-connection) that benefit from keeping state in memory in the app servers.
I'd be interested to hear about other load balancing techniques for WebSockets.