Hacker News new | more | comments | ask | show | jobs | submit login
Tracking down a memory leak in Node.js and Socket.IO (jpallen.net)
66 points by jpallen on Mar 10, 2013 | hide | past | web | favorite | 8 comments

I suspect that most folk, such as myself, have blissfully skated past such issues in ignorance because using Node.js to field SSL traffic isn't the standard setup. Instead you run an http.Server - with or without Socket.IO latched to it - behind a websocket-capable, ssl-terminating proxy like HAProxy.


Because you're going to need all the proxy features like failover, clustering, etc, etc, anyway, so why put Node.js right up front?

(Nginx recently added support for websockets, so that's now a viable alternative to HAProxy in this role, but it was aggravating for a while that it wasn't).

(I work on the same site/problem as author)

We would prefer node did not deal with the https, I actually did a previous blog post showing how performance degraded https://www.sharelatex.com/blog/posts/nodejs_http_vs_https.h....

Options like Ngnix and haproxy without pound/stud are quite recent and we have not gotten around to trying them out.

In regards to clustering, running socket.io in a cluster with redis store is another world of memory leaking pain. Hopefully socket.io 1.0 with engine.io will solve this but its been nearly released for several months now.

I am now starting to question the value of websockets, long polling is a lot simpler in many ways and robust.

I can recommend HAProxy based on my experiences.

If you want to go with established tech over newer stuff (and the Nginx websocket support is definitely too new for me - give it another 6 months at least), then you can Rube Goldberg a fun setup with Stunnel and Varnish replacing HAProxy.


I haven't had any unpleasant happenings myself with clustering Socket.IO and Redis; that'd be a topic I'd like to see a post on from your lot, given that I'm presently working on the cluster code for a demi-framework for clustered single page Node/Socket apps:


Turning on WebSockets in Nginx is a breeze, I definitely recommend doing so.

Awesome investigative work nonetheless.

Great writeup. I especially like the Telnet REPL trick:

    .createServer (socket) ->
      repl = require('repl')
      repl.start("my-node-process>", socket)
    .listen 5000, "localhost"

Thanks. I didn't invent the telnet REPL trick, but I've forgotten where I found it so I can't give credit where it's due, sorry.

A great alternative to socket.io is sock.js http://sockjs.org I've been using it in production now for a few weeks on http://worldofcardgames.com with no issues.

Applications are open for YC Summer 2019

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