my current Work Stack

  • iOS Objective-C
  • Ruby
  • Mongo
  • Rails/Sinatra
  • jQuery
  • Capistrano
  • Passenger
  • Apache.Nginx
  • Heroku
  • Nodejs
last edited 02.10.2012

here's all my posts so far

02/10 Using the Facebook SDK in an IOS Static Library
04/11 Managing Development or Sometimes work gets in the way of work
12/21 Git Stash: For when your boss|clients|life priorities change
12/09 Picker Fields in Titanium
11/30 An Update on Raphael JS and Charts
10/08 How to make a Native App Form that doesn't suck with Titanium
09/23 Notification Subscriptions in Gowalla
09/21 Developing an API in Rails
08/26 I was promised Event Driven APIs and hoverboards. Where are my hoverboards?
08/14 A Node.js wrapper for Gowalla
08/09 Phusion Passenger Tweaking: Apache stuck in Sending(W)
06/28 HTML 5 is here and breaking old hacks we should have never done!
06/26 Simple PDFkit example in Rails 3
06/23 Raphael.serialize
06/12 Serializing RaphaelJS
06/11 Rails 3 beta4 destroyed my Tie Fighter
05/21 Rails 3 and Shoulda
05/13 Using yaml to configure default options for Paperclip
05/07 It's OK to not be pretentious
04/23 Snippet #1
04/21 I Need Closure
04/16 The Good and Bad of Github
04/08 Fun with Beards, or at least mine

here's some tweets I made

I was promised Event Driven APIs and hoverboards. Where are my hoverboards?

I've been thinking a lot lately about real time fancyness and event driven async programming and how that fits really well with the American consumer mentality. We want exactly what we want, exactly when we want it.

This is also how we consume APIs. I see pollers and timeIntervals set up all over the place to continually ping for new information. How many of us have set up a TTL cache or a background or cron job to feed off twitter search? I know I have. And I always feel a little dirty doing that.

Recently I wrote a node.js gowalla library and I included built in polling for checkins and item activity. All of the lib activity is event driven, but consuming the API is still a timed interval. It made me realize that these companies could increase their efficiency by offering an event driven API.

I'm definitely not the first person to propose this. A google search yields tons of results, mostly failures. I presume they're failures because they are all XML based. (Oh! I went there!) It seems difficult, but I wonder if a simpler approach could yield strong results.

Could it be as simple as registering a RESTful POST back to your domain? You'd have to think about security, like limiting API keys to domains and possibly encoding the data with a key that you've only shared with the client. But something simple like that could cut down total requests dramatically.

If I'm pinging twitter every 5 minutes for a search result that occurs 100 times a day, I've cut my requests to 25%. I'm incurring a little more overhead from initiating the requests, but I think it still works out to less time on the network, plus you are pushing out each bit of data only once, instead of the same 20 tweets over and over again.

I don't expect anything like this to pop up soon, but it sure would be nice. And then I wouldn't have to keep writing the pollers that make me feel guilty.

An exercise for the reader: Let's say the twitter search we are polling has 1 new tweet every 2 seconds, because we searched for Bieber or some slang word that the kids are all about. How could an event driven callback improve efficiency there? Would we need some sort of limit and queueing? Could this actually make the data more accurate?

blog comments powered by Disqus