Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RethinkDB: advancing the realtime web

RethinkDB: advancing the realtime web

Originally presented at OpenWest 2015.

RethinkDB is the first database that exposes an exciting new database access model -- instead of polling the database for changes, the developer can tell RethinkDB to continuously push updated query results to applications in realtime. In this talk we'll show how this model makes building modern, realtime apps dramatically easier -- you'll learn how to get a scalable realtime web app running with RethinkDB in a fraction of the time with fewer engineering resources.

Michael Glukhovsky

May 08, 2015
Tweet

Other Decks in Technology

Transcript

  1. The open-source database
    for the realtime web.

    View full-size slide

  2. Source: http://googledrive.blogspot.com/2014/06/newdocssheetsslides.html

    View full-size slide

  3. Building realtime apps is hard
    It’s hard to keep track of state in realtime architectures.
    Realtime web
    app server
    Realtime web
    app server
    Mobile app server
    Message queue
    Database cluster
    Queues communicate
    state and messages
    between servers.

    View full-size slide

  4. Building realtime apps is hard
    Polling data to keep track of updates is cumbersome.
    Adding new realtime functionality keeps getting harder.
    Routing realtime messages vs. broadcasting messages.
    It’s hard to keep track of state in realtime architectures.

    View full-size slide

  5. What is RethinkDB?
    • Open source database for
    building realtime web apps
    • NoSQL database that stores
    schemaless JSON documents
    • Distributed database that is easy
    to scale

    View full-size slide

  6. Built for realtime apps
    RethinkDB lets you subscribe to change notifications
    on database queries.
    r.table(‘users’).changes() # Opens a changefeed on a table
    Subscribe to changes on the ‘users’ table:
    No more polling: the database pushes changes to your app,
    with a live stream of updates.

    View full-size slide

  7. Built for realtime apps
    Changefeeds let you build scalable, realtime apps.
    Realtime web
    app server
    Realtime web
    app server
    Mobile app server
    RethinkDB cluster
    Each server subscribes to
    a RethinkDB changefeed.
    Servers are stateless, and
    scale easily (just open a
    changefeed!)

    View full-size slide

  8. Built for realtime apps
    Changefeeds let you build scalable, realtime apps:
    • Collaborative web and mobile apps
    • Multiplayer games
    • Streaming analytics apps
    • Realtime marketplaces
    • Connected devices

    View full-size slide

  9. Querying RethinkDB
    r.table(‘users’)
    .pluck(‘last_name’)
    .distinct().count()
    Count unique last names with ReQL:

    View full-size slide

  10. Querying RethinkDB
    r.table(‘users’)
    .pluck(‘last_name’)
    .distinct().count()
    Count unique last names with ReQL:
    Access a database table

    View full-size slide

  11. Querying RethinkDB
    r.table(‘users’)
    .pluck(‘last_name’)
    .distinct().count()
    Count unique last names with ReQL:
    Isolate a document property

    View full-size slide

  12. Querying RethinkDB
    r.table(‘users’)
    .pluck(‘last_name’)
    .distinct().count()
    Count unique last names with ReQL:
    Consolidate duplicate values

    View full-size slide

  13. Querying RethinkDB
    r.table(‘users’)
    .pluck(‘last_name’)
    .distinct().count()
    Count unique last names with ReQL:
    Count the number of items

    View full-size slide

  14. Understanding ReQL
    RethinkDB’s query language embeds natively into
    your programming language.
    • Compose queries by chaining
    • Queries are executed and
    distributed on the server
    • Python, Ruby, JavaScript, and 20+
    other languages supported

    View full-size slide

  15. What can you do with ReQL?
    • Transformations: map, orderBy, skip, limit,
    slice
    • Aggregations: group, reduce, count, sum,
    avg, min, max, distinct, contains
    • Documents: row, pluck, without, merge,
    append, difference, keys, hasFields, spliceAt
    • Writing: insert, update, replace, delete
    • Control: forEach, range, branch, do,
    coerceTo, expr

    View full-size slide

  16. Changefeeds work on queries
    r.table(‘user_profiles’)
    .filter(r.row(‘likes’).gt(30))
    .changes()
    Get notified when a user profile gets over 30 likes:

    View full-size slide

  17. Changefeeds work on queries
    r.table(‘user_profiles’)
    .filter(r.row(‘likes’).gt(30))
    .changes()
    Get notified when a user profile gets over 30 likes:

    View full-size slide

  18. Changefeeds work on queries
    r.table(‘user_profiles’)
    .filter(r.row(‘likes’).gt(30))
    .changes()
    Get notified when a user profile gets over 30 likes:
    Clients can subscribe to this
    realtime stream of updates.

    View full-size slide

  19. Example: realtime questions
    questions.rethinkdb.com
    Let’s play with changefeeds:
    Check out the code yourself: github.com/mglukhovsky/realtime-questions

    View full-size slide

  20. Example: realtime questions
    Questions server Questions server Dashboard server
    RethinkDB cluster
    Changes are pushed to each stateless app server.

    View full-size slide

  21. Advancing the realtime web
    The push access model simplifies realtime architecture.
    One source of truth makes it easy to manage state.
    RethinkDB is the first database for the realtime web.
    Polling for data is slow, cumbersome, hard to maintain.

    View full-size slide

  22. Learn more about RethinkDB
    Get started: rethinkdb.com/install
    Read the docs: rethinkdb.com/docs
    Follow on Twitter: @rethinkdb

    View full-size slide