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
180
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
42
Introduction to RethinkDB : Hack Reactor
thejsj
4
400
Other Decks in Technology
See All in Technology
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
150
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
190
ゼロから創る横断SREチーム 挑戦と進化の軌跡
rvirus0817
2
270
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
440
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
190
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
530
なぜCodeceptJSを選んだか
goataka
0
160
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
100
Wantedly での Datadog 活用事例
bgpat
1
440
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
530
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
330
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
220
Featured
See All Featured
A designer walks into a library…
pauljervisheath
204
24k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
The Language of Interfaces
destraynor
154
24k
Bash Introduction
62gerente
608
210k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Designing for humans not robots
tammielis
250
25k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
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