Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interesting, but I'm not using Redis nor MemoryStore. I gave each machine behind HAProxy a different hostname (mapped to the same IP address), and I route the clients in roundrobin fashion to each of those before they open the page with socket.io javascript. It works like this:

- client opens a page on HAProxy load-balancer picked server

- the actual node server that receives the request, redirects the browser to its custom hostname using the same URI

- client opens the same page on the particular server and socket.io connects to that subdomain

This ensures that all future requests (if socket.io connection is broken) will go to the same server without Redis, MemoryStore, cookies or whatever.

Drawbacks:

- one additional HTTP redirect when page that contains socket.io is loaded (luckly, in games there aren't many of those)

- if you want to retire some sub-domain hostname, you have to be careful to allow existing clients to re-connect somewhere else. Not really a problem for my setup, but YMMV.



How does this work for non-socket transports? You have to be saving the broadcasts in case someone is polling, right?


I'm not sure what you mean by "saving the broadcasts". Can you give an example?

Some 11% of clients are using XHR or JSONP protocols and it it Just Works(tm), I did not add anything special.


You said you don't use Redis/MemoryStore, but when you broadcast something it has to be saved somewhere until all of the polling sessions get it. Where is it being saved?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: