Drupal and long-polling/sockets I'm looking for some ideas of how best to cater for the following scenario: I have a facebook-style feed on the front of a site that is updated with user content regularly, and just like facebook I want the page to update as nodes are submitted to the site.

So it looks to me like a classic use case for a bit of long-polling, or even using some of those new fang-dangled web sockets. But how am I going to integrate this with drupal?

There's no way I can have 20 let alone several hundred users long polling drupal directly - it would lock up every php process my system could provide.

I've been considering writing a tiny wee node.js program which would would handle all the long-polling connections and would watch the drupal node table directly. When updated, node would query drupal and proxy the request back to the clients. But this seems like a pretty awful solution to me.

Another idea I had was to load the current maximum node nid number along with the intial request, and then somehow also advertise this number via long-polling - if the advertised number changes, it would trigger the client to make a request. But I'm not sure how to implement this advertising.

So what other options are there?
Yes, implementing comet/long polling in Drupal is a bad idea.

There already is a node.js project that you could use: Drupal node.js integration.

The design principle of that module is that node.js does not contain any logic (to avoid duplication of logic in PHP and JS) but is only reponsible for keeping a connection open to your users. You then send notifications to node.js in the usual hooks (like hook_node_save()) which forwards it to your users.