45
Acquia 25. aug 9:00 Realtime with PuSH and Feeds Alex Barth Tuesday, August 24, 2010

Go real time with pubsubhubbub and feeds

Embed Size (px)

DESCRIPTION

Presented at DrupalCon Copenhagen by Alex Barth.

Citation preview

  • 1. Realtime with PuSH and FeedsAlex Barth 25. aug 9:00 Acquia Tuesday, August 24, 2010

2. Development Seed Managing NewsTuesday, August 24, 2010 3. Are we there yet?http://www.ickr.com/photos/geraldbrazell/4562022876/ Tuesday, August 24, 2010 4. Are we there yet?Are we there yet?Are we there yet?Are we there yet?Are we there yet?rss.xmlPublisherSubscriberYes. Here you are.Are we there yet?Tuesday, August 24, 2010 5. Ask developmentseed.org every 30 minutes for a new blog post, youll download11 MB for about 9Kblog posts a week.Tuesday, August 24, 2010 6. Do that for 100 similar blogsand youll download1G of data a weekjust for polling. Tuesday, August 24, 2010 7. Whats worse:Polling many feeds will back up. http://www.ickr.com/photos/geraldbrazell/4562022876/ Tuesday, August 24, 2010 8. Publish and Subscribe http://www.ickr.com/photos/geraldbrazell/4562022876/ Tuesday, August 24, 2010 9. NoticationPublisherSubscriber Tuesday, August 24, 2010 10. PubSubHubbub is aPublish and Subscribe standardTuesday, August 24, 2010 11. It solves two problems Tuesday, August 24, 2010 12. Problem 1: Tons of notications Subscriber Subscriber Subscriber Subscriber Subscriber Publisher Subscriber Subscriber Subscriber SubscriberTuesday, August 24, 2010 Subscriber 13. Problem 1: Tons of notications Subscriber Solution: Use a Hub Subscriber Subscriber Subscriber Subscriber PublisherHub Subscriber Subscriber Subscriber SubscriberTuesday, August 24, 2010 Subscriber 14. Problem 2: The thundering herd SubscriberSubscriberSubscriberSubscriberSubscriber PublisherSubscriberSubscriberSubscriberSubscriberTuesday, August 24, 2010Subscriber 15. Problem 2: The thundering herd Solution: Send whats changed (fat ping).HubSubscriberngesCha Tuesday, August 24, 2010 16. And what about RSS Cloud? Tuesday, August 24, 2010 17. PubSubHubbub is a specication Tuesday, August 24, 2010 18. Its all HTTP and XML. Tuesday, August 24, 2010 19. Tuesday, August 24, 2010 20. 1. Subscriber POSTs subscription request to the Hub. The request contains the endpoint URL where the Hub should POST new updates.I want to subscribe tofeed X, send updates to this URL:PublisherHubSubscriberFrom http://code.google.com/p/pubsubhubbub/ Tuesday, August 24, 2010 21. 2. Hub POSTs to the endpoint URL to verify the request was authentic; Subscriber responds with conrmation to the Hub. Hey there! Didyou really send this request?Publisher HubSubscriber Yup, that was really me, not a DoSattacker. From http://code.google.com/p/pubsubhubbub/ Tuesday, August 24, 2010 22. 3. Publisher noties Hub about updates by POSTing feed URLs to the Hub; Hub pulls the feed again to nd new entries.I have new content for feed X for you!Publisher Hub Subscriber Give me your latest Here you go.content for feed X,please.From http://code.google.com/p/pubsubhubbub/ Tuesday, August 24, 2010 23. 4. When Hub receives new update to feed X, it POSTs the update to the Subscribers endpoint URL. New update to feed X - here you go: Publisher Hub SubscriberFrom http://code.google.com/p/pubsubhubbub/ Tuesday, August 24, 2010 24. 5. If feed X has multiple subscribers, the Hub sends updates to all of them. This reduces load on the Publisher.New update tofeed X - here you go:Subscriber PublisherHub SubscriberSubscriberSubscriberSubscriberTuesday, August 24, 2010SubscriberFrom http://code.google.com/p/pubsubhubbub/ 25. Questions? Tuesday, August 24, 2010 26. Who supports it? Tuesday, August 24, 2010 27. Wordpress Tuesday, August 24, 2010 28. Feedburner Tuesday, August 24, 2010 29. Blogger (Google, right?) Tuesday, August 24, 2010 30. Reference Hub Tuesday, August 24, 2010 31. Hub: Superfeedr Tuesday, August 24, 2010 32. Drupal as subscriber: Feeds Tuesday, August 24, 2010 33. Drupal as publisher: 404 Tuesday, August 24, 2010 34. Check out Views content cache Tuesday, August 24, 2010 35. Drupal as hub: PuSH Hub (onboard hub) Tuesday, August 24, 2010 36. Demo time Tuesday, August 24, 2010 37. function pusher_menu() { $items = array(); $items['realtime.xml'] = array('title' => 'Realtime RSS feed','page callback' => 'pusher_feed_page','access arguments' => array('access content'),'type' => MENU_CALLBACK, ); return $items; }function pusher_feed_page() { drupal_set_header( 'Content-Type: application/rss+xml; charset=utf-8'); print pusher_feed(); } Tuesday, August 24, 2010 38. function pusher_nodeapi($node, $op) { if ($op == 'insert' || $op == 'update') { if ($node->status && $node->promote) { pusher_notify($node->nid); } } }function pusher_notify($nid) { node_load(NULL, NULL, TRUE); $changed = pusher_feed(array($nid)); push_hub_notify(url('realtime.xml', array('absolute' => TRUE)), $changed, TRUE); } Tuesday, August 24, 2010 39. David Weinberger:Small pieces loosely joined Tuesday, August 24, 2010 40. PuSHing users Tuesday, August 24, 2010 41. Mapping content between sites Tuesday, August 24, 2010 42. Check out PubSubHubbub spec Feeds module (PuSHSubscriber.inc) PuSH Hub module (PuSHHub.inc)Tuesday, August 24, 2010 43. Whats next? Solidify Subscriber support Implement Publisher support Solidify content mappingstandards Security: PuSH + OAuth Content type independenceTuesday, August 24, 2010 44. Thank you. Questions?Tuesday, August 24, 2010 45. http://cph2010.drupal.org/node/15363 Tuesday, August 24, 2010