4. • NoSQL storage for your lovely schemaless JSON documents!
• Distributed solution that is easy to scale
• Simplifies the development of realtime web apps
• And there is even more!
The open-source database
5. • More and more apps are built to be realtime
• Users want to interact with the application in realtime
• In many applications are expected to work in realtime
The realtime web
6. • Scalability vs Complexity
• State management
The realtime web is
HARD
7. • Keep everything on a single machine
• Polling database for an updates (hello Mongo oplogs)
• Use message brokers / commit logs to publish updates
The realtime web is
HARD
8. • Changefeeds - subscribing to change notifications from the code
• No more polling and brokers - RethinkDB pushes changes to your app
• Live streaming out of the box!
RethinkDB - Push
Database
9. • Collaborative web and mobile applications
• Multiplayer games
• Live streaming, monitoring and analytics
• Connected devices
RethinkDB - Push
Database
11. RethinkDB Query
Language
• ReQL embeds natively into the language
• Queries compose naturally by chaining
• Queries are executed lazily on the server
14. RethinkDB Data
Modeling
There are two ways to model relationships between documents:
• By using embedded arrays.
• By linking documents stored in multiple tables
15. RethinkDB Data
Modeling
# authors table
{
id: 123,
name: “Aleksandr”,
talks: [
{ title: “Introduction to RethinkDB” },
{ title: “Scala, the Modular Language” }
]
}
16. RethinkDB Data
Modeling
# Retrieve all authors with their talks
r.db("blog").table("authors")
# Retrieve a single author with his talks
r.db("blog").table("authors").get(ID)
18. RethinkDB Data
Modeling
# talks table
{
id: 1,
authors_id: 123,
title: “Introduction to RethinkDB”
},
{
id: 2,
authors_id: 123,
title: “Scala, the Modular Language”
}
19. RethinkDB Data
Modeling
# Simple query using filter
r.db(“blog").table("talks")
.filter(_.authors_id == 123)
# Match results from different tables
# with Join operation and secondary index
r.table(“authors”)
.getAll(“Aleksandr”, “authors”)
.eqJoin(“id”, r.table(“talks”), “authors”)
20. RethinkDB Data
Modeling
Embedded arrays vs multiple tables ???
Data modeling - http://www.rethinkdb.com/docs/data-modeling/
Table Joins - http://www.rethinkdb.com/docs/table-joins/
22. RethinkDB
Changefeeds
• The changes command creates a cursor that receives updates
• Each incoming notification includes the new and old
value of the modified record
27. Advanced realtime
web
• Polling date is slow, cumbersome and hard to maintain
• The push access model simplifies realtime architecture
• Single source of truth makes it easy to maintain state