Hacker News new | past | comments | ask | show | jobs | submit login
Using node.js, backbone.js, socket.io, and redis to make a real time chat app (fzysqr.com)
97 points by glesperance on March 9, 2011 | hide | past | favorite | 26 comments



> Yes, you read correctly. JavaScript on the server. Weird huh? That’s what I thought.

Really? It wasn't so odd back in 1996 when the Netscape web server supported it. To be sure, V8 and node have wildly better performance characteristics..but the idea of js on the server isn't exactly new: http://en.wikipedia.org/wiki/Server-side_JavaScript.


For those interested, I made a simple multiplayer Facebook card game[1] for a client using the same technologies, plus Redis and CouchDB.

The source is unobfuscated, so you can check it out if you want.

[1] http://apps.facebook.com/alloutcricket/


Just curious, how well did your card game scale? How many concurrent users could it handle? And could you easily balance the load by firing up more servers if you needed to?

The reason I ask is that everything sounds all good on paper, but how scalable is this "stack" in the real world. Would it be more scalable than relying on an xmpp network (which can be scaled wide if need be)?


> If you haven’t been reading about backbone.js, you might want to start (heh, see what I did there?).

Er, no, actually. Quick, someone sharper than I help me out!


he said the same thing about node.js at the beginning of the previous section...

that's what he did there


The more you think about it the harder it becomes.


I think this is fast becoming a stack of sorts - I just used it on an app and it scaled to 400 concurrent users beautifully.


What kind of hardware?


One Core i7 box with 8GB ram and a second database slave (for replication) with only 1GB of ram. I was running node.js, mongodb and redis all on the same box. I believe it could have handled a lot more, because it wasn't really breaking a sweat on CPU or memory usage, and my dataset was small enough to fit into memory.

Perhaps "scaled" was the wrong word, as I wasn't using multiple nodes horizontally, but you'd only have to add more database servers to scale as the load contribution of node.js was absolutely tiny.

If you were doing huge numbers you could probably also put a load balancer in front of a couple node.js application servers, each connecting to the same mongodb replica set (which you could easily scale by just throwing in more nodes). But if you're doing an app like this one, you couldn't use nginx as a load balancer because it won't proxy WebSockets.


"The cloud".


Chat app could easily kill a server just a few years ago, at least using the "default" technology available for the mass. Now there are many solutions to write a scalable chat application. This is definitely a good point :)


I like the idea of transport transparency on the client, yet very much unlike the idea of writing JavaScript on the server.

I've never tried node.js but I'm very curious to know what it offers that, say, Twisted or .NET or any other framework with proper IO facilities doesn't.


I know its on Github, but a hosted demo would've been nice. I finally understood what backbone.js is. Seen posts all over HN not knowing what it is. Guess i had to understand what MVC is first(!) . Can you tell im new to programming? ;-)


I was afraid of the internet, but here you go. http://fzysqr.no.de:8000/ Don't use your real passwords.


Watch out for xss! use `.text()` :)


Yep. Required a few hotfixes.


Joyent gave nodechat better home! http://nodechat.no.de/


ah, another chat program on node.js


It's node.js' equivalent to a Haskell monad tutorial.


Good point. Never thought of it that way. Even so there are a lot that seem to make it to the front page.


It was actually the same application i was using to test Java IDEs in 1996.

http://www.javarants.com/suba/html/visualj++.htm


Quick survey: if you could have the equivalent of this stack, with persistence, as a service, would that be interesting to you?

It would be RESTful relational database-as-a-service but where any individual item could show updates in real time. (E.g. real-time chat would just be a Javascript component.)


No


Yes


I've been looking for something like this! Can't wait to get started and fire up my chat server. Thanks!


I made a real-time chat app at a hackathon using this stack - minus backbone:

http://www.hubabl.com




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: