Friday, September 4, 2015

Adapting RethinkDB For The Evented Web With Pusher

Pusher_rethinkDB_demo

RethinkDB recently released version 2.0, and here at Pusher we're all very excited about how creating real-time apps can now be even easier. Changefeeds, a feature introduced by RethinkDB a few versions ago, allows your system to listen to changes in your database. This new version has significantly improved, opening up interesting possibilities for real-time applications.

While RethinkDB covers listening to events on your server, there is still the issue of publishing these changes to your client, who can build anything from news feeds to data visualizations.

This is where a hosted message broker such as Pusher comes into play. By exposing RethinkDB changefeed changes as Pusher events, you can quickly achieve scalable last-mile delivery that instantly pushes database updates to the client. Not only that, but Pusher's evented publish-subscribe approach fits the logic of real-time applications:

  • Channels identify the data, whether that's a table in a database or, in the case of RethinkDB, a changefeed.
  • Events represent what's happening to the data: new data available, existing data being updated or data being deleted.

As an added bonus, real-time features can be rolled into production fast, in the knowledge that Pusher will scale to millions of concurrent devices and connections, removing the pain of managing your own real-time infrastructure.

To show you how this can be done, this post will guide you through how to create the type of activity streams found on the RethinkDB website. By creating a small Sinatra app, we'll quickly build the JSON feed and high-scores list you can see in our demo. Note that while we are using Ruby and Sinatra, one of the great things about RethinkDB's adapters is how similar they are across all languages. In other words, what we do here can easily be applied to the stack of your choice.

Continue reading %Adapting RethinkDB For The Evented Web With Pusher%


by Jamie Patel via SitePoint

No comments:

Post a Comment