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
Perlの生きのこり - エンジニアがこの先生きのこるためのカンファレンス2025
kfly8
1
220
わたしのOSS活動
kazupon
2
300
依存パッケージの更新はコツコツが勝つコツ! / phpcon_nagoya2025
blue_goheimochi
3
180
Share my, our lessons from the road to re:Invent
naospon
0
110
Oracle Cloud Infrastructure:2025年2月度サービス・アップデート
oracle4engineer
PRO
1
350
Helm , Kustomize に代わる !? 次世代 k8s パッケージマネージャー Glasskube 入門 / glasskube-entry
parupappa2929
0
270
コンテナサプライチェーンセキュリティ
kyohmizu
1
110
OpenID BizDay#17 みんなの銀行による身元確認結果の活用 / 20250219-BizDay17-KYC-minna-no-ginko
oidfj
0
140
開発組織のための セキュアコーディング研修の始め方
flatt_security
3
2.7k
The Future of SEO: The Impact of AI on Search
badams
0
240
データ資産をシームレスに伝達するためのイベント駆動型アーキテクチャ
kakehashi
PRO
2
610
2/18/25: Java meets AI: Build LLM-Powered Apps with LangChain4j
edeandrea
PRO
0
150
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
KATA
mclloyd
29
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.3k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
Building a Scalable Design System with Sketch
lauravandoore
461
33k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
Embracing the Ebb and Flow
colly
84
4.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Typedesign – Prime Four
hannesfritz
40
2.5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
9
500
Git: the NoSQL Database
bkeepers
PRO
427
65k
Gamification - CAS2011
davidbonilla
80
5.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