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
54
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
cdkd (CDK Direct)
gotok365
4
270
re:Invent2026 事前勉強会 歴史と愉しみ方10分LT編
toshi_atsumi
0
160
会社説明資料_最新版
demaecan
0
32k
Shared Signals Framework 仕様解説
oidfj
0
280
eBPF 簡介 2026 版
shunghsiyu
0
190
Sinatra on PicoRuby ローカルでセルフホスト
bash0c7
0
110
SSFの現在地 ― CAEP/RISCからAI Identityへ
oidfj
0
280
PostgreSQL オプティマイザ統計の秘密
nori_shinoda
0
430
公共分野での生成AI活用
toru_kubota
1
300
超⼩型・多⾔語検索モデル Bekko Embedding
hotchpotch
1
130
仕様と現実の間で落とし所を探るリモートMCPの認証・認可 — Sansanの認証基盤における課題と実践
sansantech
PRO
2
170
Copilot Coworkで「みのるん式」やってみた
minorun365
PRO
2
1.6k
Featured
See All Featured
How to make the Groovebox
asonas
2
2.5k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
70
68k
Evolving SEO for Evolving Search Engines
ryanjones
0
360
エンジニアに許された特別な時間の終わり
watany
109
250k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
121
130k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
290
sira's awesome portfolio website redesign presentation
elsirapls
0
500
A better future with KSS
kneath
240
18k
Why Our Code Smells
bkeepers
PRO
340
58k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
880
Rails Girls Zürich Keynote
gr2m
96
14k
GitHub's CSS Performance
jonrohan
1033
470k
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