Matt Warren

Playing With Node.js

When exploring ways to build a good chat server there are an overwhelming number of options.

The old way of doing things with polling the server for new messages was simply not an option but the alternatives are a little scary.  Using a SQL database seemed a bit overkill for just posting messages.

In the python world the asychronous server options which would support either raw sockets or websockets include Tornado, Twisted, and gevent.  The other option was to try out Node.js.

Chat servers seem to be the de-facto example app for these types of server frameworks.  Yet unfortunately there are very few full featured examples to be found.

I initially wrote a chat server that worked with raw sockets using Twisted.  However, testing the raw socket solution proved annoying, and creating a web based admin for the chat server would require yet another service to convert the raw socket into a websocket or develop a native client app for communicating to the server.

So I took a step back and started again with Node.js.  Node.js with socket.io proved to be quite a bit simpler to code than the raw sockets on Twisted option.  Using websockets will add a requirement on my iOS client for a library, but it makes things much easier to test through a html client.

For the persistence backend there are also many different options.  I have an existing MySQL server that I could have used, but I was interested in trying something a bit leaner.  Both Redis and MongoDB stood out.  At the moment I’m still evaluating which backend to use.

So it’s not quite finished enough to share the code.  I’ll put it up on github when it’s finished.


Posted

in

by

Tags: