Justin Randell on Real-Time Push Notifications with the Node.js Integration Module

Podcast episode player
0:00 0:00

Justin Randell talks about the node.js integration module that he wrote in order to facilitate real-time chat and push notifications by using node.js and Express. He sees a lot of potential of Drupal using this with HTML5 in order to create dynamic, real-time mobile websites.

Randell is also the maintainer of the D6 version of the chatroom Drupal module, which he says is not currently a highly scalable IRC or XMPP style solution since it relies upon polling. But with the D7 version, he'd like to integrate the chatroom module with node.js so that it could be a highly scalable, real-time chat solution.

So what's the difference between the node.js integration module and nodepal?

The node.js integration is an API module that serves as a real-time pipe from Drupal to node.js/Express so that other Drupal modules can use functionality as provided from node.js. On the other hand, nodepal is so that node.js developers can write node.js apps that use functionality from Drupal.

From this comment on g.d.o., Randell explains why implementing real-time functionality from within Drupal is less than optimal, and how this approach help fix it.

Either you use polling, which eat servers, or you use push (via websockets, flash sockets, long polling, etc), but then you have a fat Drupal process just sitting there, and you eat servers just as quickly.

What the node.js integration module seeks to do is:

  • Keep the 'always open' socket handling with node.js, because node.js is able to handle large numbers of these without much fuss. node.js code does little more than this, its dumb by design
  • Keep all the smarts with Drupal, e.g., clients connect to node.js, but authentication is handled by Drupal, content creation is handled by Drupal
  • Allow other modules to easily use nodejs.module's API to send realtime/push information to browsers

So Randell is trying to keep the node.js code as lightweight and dumb as possible since it's strength is in maintaining many persistent connections and holding open a socket to many thousands of clients concurrently without tying up an apache child process.

There were a couple of well-attended Birds of a Feather sessions at DrupalCon Chicago, and he's sees that there's a lot of excitement about how this can bring more real-time functionality to Drupal.