Why I love NodeJS and Redis

Posted on: in General | 3 Comments »

Over the past few weeks and months I have used quite a bit of NodeJS and Redis when I am developing. Now I am nowhere near a full-time developer. I am mainly doing Lean Startup consulting, Agile Coaching and Storytelling workshops, but at one of my clients I am also helping out developing an MVP when time permits.

But before I get to the good bits, let’s start with all the reasons why I do not love Node and Redis.

It’s Javascript

Some people say it is great to be able to run (the same) Javascript on both the server and the clients. I am sure that would be great, but a) I don’t like Javascript (which is why I use Coffeescript) and b) I mostly do JSON based web services and can’t even write a line of client-side javascript.

Performance

Node and Redis are incredible to attain a great performance. They are insanely fast. A simple REST service in Node with a Redis backend is able to serve sub-ms response times per request. At a couple thousand concurrent connections! On a laptop! Try that with Java on an application server.
But I am afraid we would be fairly happy with a request a minute now. Doing it in BASIC with a flat file database would be fast enough.

Scalability

Especially since most of my Node servers are stateless, the scalability possibilities are endless. Fire up another machine, install Node and point it to Redis. Saturating Redis is no small feat in and of itself, but even once I would manage to do that, I would just fire up a Redis slave. It’s not until you saturate a Redis instance with writes that you need to start worrying about sharding. And I don’t even want to know how many requests/sec that is on decent hardware.
But just as above, we would be happy with a couple of requests per minute now. We can’t even get a EC2 micro instance to work up a slight sweat.

npm

NPM is awesome, it has some nifty advantages over other language equivalents like maven, gems, rake and groovy. The best thing is that they do transitive dependencies properly. In that you do not care about them. My dependencies have their dependencies and that’s great. I have mine. If we happen to have the same dependency with different versions? Great. Fine. Try that in Java :)
So they are doing things right, but it is not really a game changer in its own.

So why the hell do I love Node so much?

It allows me to get sh*t done

As I mentioned before, I am mostly helping out a development team by implementing a JSON service for them now and then that they need. Either from scratch or as an interface into the company big bad internal systems.
And with both Node and Redis I can usually do that in a day. Maybe 2 or 3 if it is really complicated.
So how comes?

Simplicity
There is no fat in either Node or Redis. They are bare bones and low-level, but at an extremely useable level. There are no fancy containers, no installation manuals. Node is node and Redis is redis-server. The absence of magic is a great sense of relief for me.
Redis’s best command is MONITOR. See in real-time what queries are happening. Copy and paste a command in another redis-cli and see the actual text commands being send back. Awesome!

Community
Both Node and Redis have great maintainers. Salvatore Sanfilippo [twitter-follow screen_name='antirez'] (the author of Redis) is a freak when it comes to the quality and reliability of Redis. Ryan Dahl [twitter-follow screen_name='ryan'] recently passed the torch to Isaac Schlueter [twitter-follow screen_name='isaacs'] and both are extremely capable guys. But what makes the communities great is the adoption by others. And the quality of their contributions. There is TJ’s [twitter-follow screen_name='tjholowaychuk'] Express and Mikeal’s [twitter-follow screen_name='mikeal'] Request library for example and his efforts in organizing conferences.
And let’s not forget the huge amount of information out there on things like Stackoverflow on Javascript in general and Node in particular.

Documentation
The Node documentation is pretty darn good, but Redis has it beat by a mile. It is by far the best documentation I have ever seen. Extremely concise but very clear. And the best part it has a live example. Below every command in the Redis documentation you can experiment with the command to see what happens if you do that. I hardly ever wonder about anything Redis for more than about 35 seconds.

Libraries
The NodeJS library ecosystem is awesome right now. Lots and lots of small building blocks that do one thing really well. It is the Unix command line ethos all over again. But now combined with the power of the web.
Here is a list of stuff I use a lot:

express – HTTP Server framework.
connect – Middleware for said HTTP Server framework
async – Exact control on the flow of your application
request – Everything you ever wanted to do with HTTP requests
commander – Node is not just for the web
xml2object – SAX parser that converts XML snippets to JSON

As you can see there is no kitchen sinks in sight :)

All of this allows me, a fairly decent Java developer with hardly any Javascript skills, to solve real world problems in record time.
And that’s why I love Node and Redis.

Tags: , , , , , , , , , , , ,

Leave your reply

  1. Pingback: Cheatsheet: 2012 04.01 ~ 04.12 - gOODiDEA.NET

  2. Interesting project. Shall have to take a look at it at some point. Although I am a bit allergic for projects that describe themselves by what they are not.
    And I detect a bit of a “We are not NodeJS” vibe going on.