Friday, June 11th, 2010

Connect: Great middleware for Node!

Category: Node

Tim Caswell has been doing awesome work, and his latest project is Connect, a high performance middleware framework for node.js. Ruby has Rack. Python has WSGI. Java has Servlets. Now, JavaScript has Node/Connect.

I was able to set it up in minutes and took the following screencast of a sample application in action:

Take a peak at the examples as they show you how easy it is to rack up the middleware. In the Raphael circle multi-touch collaborative dragging example shown, you get a nice set of filters:


  1. module.exports = new Connect.Server([
  2.     {filter: "log"},
  3.     {filter: "response-time"},
  4.     {filter: "body-decoder"},
  5.     {provider: "pubsub", route: "/stream", logic: Backend},
  6.     {filter: "conditional-get"},
  7.     {filter: "cache"},
  8.     {filter: "gzip"},
  9.     {provider: "cache-manifest", root: root},
  10.     {provider: "static", root: root}
  11. ]);

Awesome. And with the Heroku support it is tempting to git a version up there and see how many Ajaxians can muck around with it….

Posted by Dion Almaer at 6:20 am

3.3 rating from 4 votes


Comments feed TrackBack URI

Actually, JSGI is really the middleware of JavaScript. Connect is node-specific, and is actually much slower and has critical flaws compared to JSGI:

Comment by kriszyp — June 11, 2010

And Perl has Plack (

Comment by patspam — July 7, 2010

Connect’s has grown and changed a lot since this article. The new code is at SenchaLab’s account on github

As far as being slow, the sitepen article pulls apart a very minute part of the total cost of serving a web page and shows that that particular part of connect is several times slower than JSGI. This is totally irrelevant since the overall cost of serving a website is not affected in any significant way by the difference. In fact, connect’s built-in layers and filters can make a basic setup be able to serve 35,000 requests/second of real http traffic over a lan for small responses. For large responses I’ve clocked it at 40% faster than nginx or apache on the same machine! Connect is many things, but slow is not one of them.

Connect is node specific on purpose and this is a feature!

Comment by creationix — August 25, 2010

Leave a comment

You must be logged in to post a comment.