Realtime apps
• More and more apps are built to
be realtime
• Users have come to want and
expect this behavior in their apps
Slide 7
Slide 7 text
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
Slide 8
Slide 8 text
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.
Slide 9
Slide 9 text
Introduction
What is RethinkDB?
Slide 10
Slide 10 text
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
Slide 11
Slide 11 text
Built for Realtime Apps
• Subscribe to change notifications
from database queries
• No more polling — the database
pushes changes to your app
• Reduce the amount of plumbing
needed to stream live updates
Slide 12
Slide 12 text
Built for Realtime Apps
RethinkDB is an excellent database for:
• Collaborative web and mobile apps
• Multiplayer games
• Streaming analytics apps
• Realtime marketplaces
• Connected devices
Slide 13
Slide 13 text
Introduction to ReQL
RethinkDB Query Language
Slide 14
Slide 14 text
Introduction to ReQL
• ReQL embeds natively into your
programming language
• Compose ReQL queries by
chaining commands
Slide 15
Slide 15 text
Anatomy of a ReQL Query
r.table("players")
.orderBy({
index: r.desc("score")
})
.limit(3)
Top three players by score
Slide 16
Slide 16 text
Anatomy of a ReQL Query
r.table("players")
.orderBy({
index: r.desc("score")
})
.limit(3)
Access a database table
Slide 17
Slide 17 text
Anatomy of a ReQL Query
r.table("players")
.orderBy({
index: r.desc("score")
})
.limit(3)
Order results
Slide 18
Slide 18 text
Anatomy of a ReQL Query
r.table("players")
.orderBy({
index: r.desc("score")
})
.limit(3)
Use index as pre-processed lookup
Slide 19
Slide 19 text
Anatomy of a ReQL Query
r.table("players")
.orderBy({
index: r.desc("score")
})
.limit(3)
Order results in descending order
Slide 20
Slide 20 text
Anatomy of a ReQL Query
r.table("players")
.orderBy({
index: r.desc("score")
})
.limit(3)
Only get the first three results
Slide 21
Slide 21 text
Subscribe to change notifications
on database queries
Changefeeds
Slide 22
Slide 22 text
r.table("users").changes()
Track changes on the users table
Changefeeds
Slide 23
Slide 23 text
Changefeeds
r.table("players")
.orderBy({
index: r.desc("score")
})
.limit(3)
.changes()
Get updates on top three players