Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Realtime Apps with RethinkDB and Node.JS
Search
MattCollins84
September 14, 2016
Technology
52
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Realtime Apps with RethinkDB and Node.JS
Taking a look at building Realtime Apps with RethinkDB and Node.js
MattCollins84
September 14, 2016
Other Decks in Technology
See All in Technology
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
110
スプシの手作業からの解脱 ~更新はClaude Codeに、見せ方と使い方はGASアプリに任せる~
kentarofujii
0
150
AI時代のPRレビューにどう向き合うか?
kairim0
1
240
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
460
AI駆動で「他アプリの音を加工できる」アプリを作った
satomasahiro2005
0
160
How to Design Configuration for Rails Applications
willnet
1
810
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
180
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
4
1.1k
Running Kotlin + Quarkus with Lambda
nealle
1
3.8k
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
1.7k
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
1
230
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Are puppies a ranking factor?
jonoalderson
2
4.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
490
Thoughts on Productivity
jonyablonski
76
5.4k
KATA
mclloyd
PRO
35
16k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Practical Orchestrator
shlominoach
192
12k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Code Reviewing Like a Champion
maltzj
529
40k
Design in an AI World
tapps
1
350
Transcript
Realtime Apps ...with RethinkDB and Node.JS MattCollins84
Realtime Apps ...with RethinkDB and Node.JS MattCollins84
What do we mean by “Realtime App”?
Pushing data to the user is what makes your app
“realtime”.
None
Interactive Alive Engaging
Great User Experience
:(
Tracking state in realtime apps is hard
The database holds the state of your app Databases are
slow Polling doesn’t scale
DB Message Queue App Server
DB Message Queue App Server
DB Web Queue Web App Server Mobile App Server Mobile
Queue
DB Web Queue Web App Server Mobile App Server Mobile
Queue Web App Server Web Queue
Open Source NoSQL DB JSON document store Distributed Really nice
admin UI Designed for building realtime apps! Own query language - ReQL
RethinkDB Application cursor.next() cursor.each( (err, item) => { … }
) cursor.toArray( (err, results) => { … } )
r.db("nottsjs") .table("questions") [ { id: "cad7-470d-b8d0-e89900bcda0d", question: "What is your
favourite colour?" score: 10 }, { id: "d5c9-d104-0d31-1c2f199b", question: "Where were you born?" score: 5 } ]
r.db("nottsjs") .table("questions") .filter( r.row("score").gt(5) ) [ { id: "cad7-470d-b8d0-e89900bcda0d", question:
"What is your favourite colour?" score: 10 } ]
r.db("nottsjs") .table("questions") .changes() { new_val: { "id": "2cc9-497a-ae25-69c6710a9181" , "question":
"How old are you?" , "score": 0 }, old_val: null }
RethinkDB Cluster Web App Server Web App Server Mobile App
Server
RethinkDB Demo
JavaScript runtime Built on Googles V8 engine Non blocking I/O
Event Driven Single threaded
I/O I/O
I/O
Never Block The Event Loop
RethinkDB in Node.js npm install rethinkdb
Querying RethinkDB const r = require("rethinkdb"); r.connect((err, conn) => {
r.table("questions").run(conn,(err, cursor)=> { cursor.toArray((err, results) => { conn.close(); console.log(results); }) }) })
Querying RethinkDB const r = require("rethinkdb"); r.connect((err, conn) => {
r.table("questions").run(conn,(err, cursor)=> { cursor.toArray((err, results) => { conn.close(); console.log(results); }) }) })
Querying RethinkDB const r = require("rethinkdb"); r.connect((err, conn) => {
r.table("questions").run(conn,(err, cursor)=> { cursor.toArray((err, results) => { conn.close(); console.log(results); }) }) })
Querying RethinkDB const r = require("rethinkdb"); r.connect((err, conn) => {
r.table("questions").run(conn,(err, cursor)=> { cursor.toArray((err, results) => { conn.close(); console.log(results); }) }) })
Changefeeds are similar... const r = require("rethinkdb"); r.connect((err, conn) =>
{ r.table("questions").changes() .run(conn,(err, cursor)=> { cursor.each((err, event) => { console.log(event) }) }) })
Changefeeds are similar... const r = require("rethinkdb"); r.connect((err, conn) =>
{ r.table("questions").changes() .run(conn,(err, cursor)=> { cursor.each((err, event) => { console.log(event) }) }) })
Changefeeds are similar... const r = require("rethinkdb"); r.connect((err, conn) =>
{ r.table("questions").changes() .run(conn,(err, cursor)=> { cursor.each((err, event) => { console.log(event) }) }) })
Putting everything together
App GET /questions POST /question App App App App RethinkDB
App .changes() io.emit('new', q) RethinkDB App App App App io.emit('new',
q) io.emit('new', q) io.emit('new', q) io.emit('new', q)
Socket.IO npm install socket.io
r.table("questions").changes() .run(conn, (err,cursor) => { cursor.each((err, e) => { if
(!e.old_val && e.new_val) { io.emit('new-q', e.new_val) } }); });
<script src="/socket.io/socket.io.js"></script> <script> var socket = io(); io.on('new-q', q =>
{ // do something with this data }) </script>
www.rethinkdb.com www.nodejs.org www.compose.com http://bit.ly/2ciJ17Y
Demo