Scale out socketio to multiple servers(same port) with node-http-proxy

192 views
Skip to first unread message

hd nguyen

unread,
Jul 27, 2012, 7:21:27 AM7/27/12
to nod...@googlegroups.com
Hi all,

I did some google search but still not found any example/tutorial for my case.

Assume I have a nodejs app using socket io, and I want to use node-http-proxy as load balancer.

My app is replicated in 2 servers with the same port.

server1: myapp_url:8000
server2: myapp_url:8000

How I can configure through node-http-proxy so user just browse to http://proxy_url:proxyport, then request will be redirected to server1 or server2 automatically based on load balancing algorithm?

And does node-http-proxy support load balancing algorithm efficiently and transparently? I saw on github site just a simple round robin algorithm, I'm supposed that such thing should be transparent with developer, we just need to configure only?

Thanks for your time. 

--
Nguyen Hai Duy
Mobile : 0914 72 1900
Yahoo: nguyenhd_lucky

Bradley Meck

unread,
Jul 27, 2012, 10:08:20 AM7/27/12
to nod...@googlegroups.com
Load balancing is outside the scope of node-http-proxy. Configuration of load balancing algorithms is complex and least common denominator often leads to problems with things that use in memory storage across connections such as non-database sessions etc. There are multiple examples on npm and github of load balancers using node-http-proxy, but I doubt it will ever support configuration only load balancing.

For socket.io in particular I would recommend using source to destination IP hashing, so that the same client always reaches a consistent server per proxy, but even that is only a few lines of code inside of your proxy.

hd nguyen

unread,
Jul 27, 2012, 10:51:22 AM7/27/12
to nod...@googlegroups.com
Of course we can write a code snippet to redirect request to expected server manually by node-http-proxy.

Based on https://github.com/nodejitsu/node-http-proxy/ examples, I just can find snippet code to stick from proxy server to ONE nodejs (using websocket/socket.io), I want redirecting from proxy server to 2 or more servers (replication).

I guess node-http-proxy would be supporting it, because sticking from one proxy to one server is not quite useful.

Waiting for more suggestions, thanks.

On Fri, Jul 27, 2012 at 9:08 PM, Bradley Meck <bradle...@gmail.com> wrote:
Load balancing is outside the scope of node-http-proxy. Configuration of load balancing algorithms is complex and least common denominator often leads to problems with things that use in memory storage across connections such as non-database sessions etc. There are multiple examples on npm and github of load balancers using node-http-proxy, but I doubt it will ever support configuration only load balancing.

For socket.io in particular I would recommend using source to destination IP hashing, so that the same client always reaches a consistent server per proxy, but even that is only a few lines of code inside of your proxy.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
Reply all
Reply to author
Forward
0 new messages