Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Push databases: A better way to build realtime ...
Search
Jorge Silva
July 08, 2015
Technology
0
120
Push databases: A better way to build realtime apps
Jorge Silva
July 08, 2015
Tweet
Share
More Decks by Jorge Silva
See All by Jorge Silva
Introduction to RethinkDB : Move fast and break things
thejsj
2
250
ForwardJS - RethinkDB - Getting Started
thejsj
0
180
ForwardJS - RethinkDB - Advanced Queries
thejsj
1
190
Automatic Failover in RethinkDB
thejsj
0
220
Workshop: Introduction to RethinkDB : Santa Cruz JS
thejsj
1
110
Data Modeling in RethinkDB
thejsj
4
260
RethinkDB+Angular.js: Building realtime web applications
thejsj
10
30k
Introduction to RethinkDB: 1KE Meetup
thejsj
0
43
Introduction to RethinkDB : Hack Reactor
thejsj
4
400
Other Decks in Technology
See All in Technology
あなたの知らないクラフトビールの世界
miura55
0
140
GoogleのAIエージェント論 Authors: Julia Wiesinger, Patrick Marlow and Vladimir Vuskovic
customercloud
PRO
0
190
WantedlyでのKotlin Multiplatformの導入と課題 / Kotlin Multiplatform Implementation and Challenges at Wantedly
kubode
0
250
デザインシステムを始めるために取り組んだこと - TechTrain x ゆめみ ここを意識してほしい!リファクタリング勉強会
kajitack
2
200
ゼロからわかる!!AWSの構成図を書いてみようワークショップ 問題&解答解説 #デッカイギ #羽田デッカイギおつ
_mossann_t
0
1.6k
生成AIのビジネス活用
seosoft
0
110
.NET 最新アップデート ~ AI とクラウド時代のアプリモダナイゼーション
chack411
0
200
20250122_FinJAWS
takuyay0ne
2
110
Godot Engineについて調べてみた
unsoluble_sugar
0
440
Building Scalable Backend Services with Firebase
wisdommatt
0
110
完全自律型AIエージェントとAgentic Workflow〜ワークフロー構築という現実解
pharma_x_tech
0
370
PaaSの歴史と、 アプリケーションプラットフォームのこれから
jacopen
7
1.5k
Featured
See All Featured
Designing Experiences People Love
moore
139
23k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Building an army of robots
kneath
302
45k
Mobile First: as difficult as doing things right
swwweet
222
9k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Scaling GitHub
holman
459
140k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Transcript
Push databases A better way to build realtime apps Bay
Area OpenSource Palo Alto, CA July 8, 2015
Jorge Silva Developer Evangelist @ RethinkDB @thejsj
Preface Why is realtime important?
Realtime apps
Realtime apps
Realtime apps • More and more apps are built to
be realtime • Users have come to want and expect this behavior in their apps • Building realtime apps is hard
Building realtime apps is hard • You can keep everything
in a single server • You can poll the database to keep track of updates • You can publish updates through a message broker
Building realtime apps is hard • All solutions present a
tradeoff between scalability and complexity • It’s hard to keep track of state in realtime architectures
Introduction What is RethinkDB?
What is RethinkDB? • Open source database for building realtime
web applications • NoSQL database that stores schemaless JSON documents • Distributed database that is easy to scale
Push Database • Subscribe to change notifications from database queries
(changefeeds) • No more polling — the database pushes changes to your app • Reduce the amount of plumbing needed to stream live updates
Push Database • Having your database push changes keeps your
database as the central source of truth • Having a central source of truth simplifies your architecture
Push Database RethinkDB is an excellent database for: • Collaborative
web and mobile apps • Multiplayer games • Streaming analytics apps • Connected devices
Introduction to ReQL RethinkDB Query Language
Introduction to ReQL • ReQL embeds natively into your programming
language • Compose ReQL queries by chaining commands
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Number of
unique last names
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Access a
database table
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Isolate a
document property
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Consolidate duplicate
values
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Display the
number of items
Sample ReQL Queries r.table("users") .filter(r.row("age").gt(30)) r.table(“post") .eqJoin(“uId”, r.table(“users”)) .zip() r.table("fellowship")
.filter({species: "hobbit"}) .update({species: "halfling"})
Additional ReQL Features • Geospatial indexing for location- based queries
• Date and time functions • Support for storing binary objects • Execute http requests using r.http
Realtime Updates Working with Changefeeds
Subscribe to change notifications on database queries Changefeeds
r.table("users").changes() Track changes on the users table Changefeeds
Changefeeds • The changes command returns a cursor that receives
updates • Each update includes the new and old value of the modified record
Changefeeds r.table("users").changes() r.table("users") .insert({name: "Bob"}) Changefeed output: { new_val: {
id: '362ae837-2e29-4695-adef-4fa415138f90', name: 'Bob', ... }, old_val: null }
Changefeeds r.table("users").changes() r.table("users") .filter({name: "Bob"}).delete() Changefeed output: { new_val: null,
old_val: { id: '362ae837-2e29-4695-adef-4fa415138f90', name: 'Bob', ... } }
Changefeeds r.table("users").changes() r.table("users") .get("362ae837-2e29-4695-adef-4fa415138f90") .update({name: "Bobby"}) Changefeed output: { new_val:
{ id: '362ae837-2e29-4695-adef-4fa415138f90', name: 'Bobby' }, old_val: { id: '362ae837-2e29-4695-adef-4fa415138f90', name: 'Bob' } }
Changefeeds r.table("players") .orderBy({index: r.desc("score")}) .limit(3).changes() Track top three players by
score Chain the changes command to an actual ReQL query:
Questions http://questions.rethinkdb.com
Summary • Keeping track of state in realtime apps is
hard • RethinkDB solves this problem by pushing changes to your app • In the future, we'll see more database that use the push model
Questions • RethinkDB website: http://rethinkdb.com • Install RethinkDB: http://rethinkdb.com/install/ •
Email me:
[email protected]
• Tweet: @thejsj, @rethinkdb