You are currently browsing the tag archive for the ‘server’ tag.

Been ultra busy lately on two distinct web projects, both of which really need a good architecture so they can scale easily.

One nice way to do this is with services which message each other – if you have a fast, persistent reliable message queue you can have many processes grab jobs off the queue and thus scale out over many cores.  I feel this is a natural way to scale out node.js apps.

I immediately discarded SQS [ Amazon’s scalable queue service ] as it basically polls a web url to check for messages, so it really is not a message queue at all.

Another nice option is Mongo tailable cursors, which is the message queue approach that mongo uses internally to replicate between mongo instances.   This worked sort of ok, but didnt strike me as ultra high performance.  see mongoMQ npm module for a simple api wrapper.

I was very impressed with Redis Publish/Subscribe semantics… which are very fast, but dont have persistence.

In the end I decided to use a combination of Redis pub/sub for notifications, and Redis List operations rpush/lpop to store/retrieve the actual message data.  I wrapped this in a simple node.js api, which Im calling redpill.

I have an initial implementation of a typical web app which has users and info items.  This performs rather well, with web request response times under 50ms whle 1000 items/sec are being inserted as a background task.

The nice thing is that using message queues allows you to scale up by running any number of servers.

See code + comments here :

redpill : persistent messaging using Redis primitives

gorgon : demo web server architecture with messaging between server components

Lots of things to optimise, but basically a good proof of concept and initial working demo code for this approach.

Been hacking in Node.js and am really enjoying the saneness of this dev environment.

Some handy links before I forget  :

  • howto.no.de articles – especially Part I, II and III of ‘Learning Javascript with Object Graphs’
  • Joyeur blogs – people working for Joyent on Node / DTrace / Solaris
  • no.de Joyent Node hosting [ built atop – ‘open’ solaris, ZFS, DTrace ]
  • NodeJitsu blog
  • npm.mape.me – searchable Node.js Modules list
  • connect-it guide – web framework with chained middleware layers
  • express guide – article on express web framework for Node
  • eventserver – Tom Lee’s internet tee piping for notifications

In other news.. Im hacking over ssh via a long thin pipe to my linode server – using a very erratic mobile broadband connection, arrgh!

Cant wait for ADSL to _finally_ be connected here, so I can watch Bryan Cantrill talk about Cloud Analytics :]

As an aside.. why Javascript?  Consider

  • Javascript is a totally distinct language from Java
  • Javascript deserves its bum rap.. to mis-quote Dame Judi Dench, its bad parts are “arse-clench-ingly” bad :]
  • The good parts of Javascript feel very nice, like a modern lisp inspired language, fairly concise, many valid idioms
  • V8 js engine is fast
  • Javascript callback mechanism fits async event IO really well
  • Node.js embodies the above bullet point into a fine server development environment
  • JSON, the Javascript native data format, is all the good things of XML with none of the bad
  • feels like a unix-like web-plumbing philosophy
  • can keep the same language syntax hat on when writing front end web apps and back end servers

Lately I seem to be busy mainly with consulting to Internet and Mobile startups, and one of the things I get asked a lot is which technologies I recommend for a given project.

It seems to work best when I give two approaches to serving data, one based on newer tools such as Node.js and CouchDB along with a more conservative alternative using Ruby on Rails or traditional LAMP stack as underlying technology.

As a prelude to the detailed project plan and data design, I usually give an overview of current trends.. I get asked that a lot, so I thought Id put my observations online here as a few bullet points :

Technology Trends :

  • Web and Mobile projects are converging [one usually implies the other]
  • Most data is social data [for the user and the people they interact with]
  • Most data naturally fits a tree or graph structure [tabular, not so much]
  • JSON has replaced XML [hand-in-glove with web, iPhone, Android ]
  • Scalability is a feature [can be deferred, but no easy migration path]
  • The days of generating HTML from PHP are gone [use JSON feed + jQuery]
  • People still use PHP and MySQL [it works, you can find developers]
  • Code using MVC frameworks tends to be overly verbose [Zend, Rails, Django]
  • Node.js and CouchDB are cool [but the newness of NoSQL is risky]

These are universally accepted as a good thing :

  • iPhone vs Android : both are good, competition is great!
  • JSON
  • jQuery
  • Architecture :  [ server data store ] <–> [ JSON ] <–> [ Web / Mobile client ]
  • AppStore revenue model

These are technologies to watch for :

  • Node.js [ultra high performance app servers can be written in Javascript ]
  • CouchDB [scalable NoSQL with sane REST api, map/reduce in Javascript ]
  • SVG [allows new kinds of User Interface on web & mobile ]

The above observations and predictions raise some interesting questions.. but Ill save that as juice for another post.