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
55
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
Transcript
41 slides
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
Other Decks in Technology
See All in Technology
社内アプリ基盤「Quartz」による、 非エンジニアとAIに本番デプロイを 任せても壊れないプラットフォームの設計
staka121
PRO
1
240
「正しいデータ」の定義をAI エージェントとつくるGoogleADKによるデータ品質定義の実践
takaha4k
0
140
フロントエンドのテストカバレッジは 100%強制がいい
bengo4com
7
3k
みん強Lightning! データ基盤ひとりでできるかな
endonanana
0
220
New Relicのアラート対応をClaude Codeで自動修正するワークフローを作った話
manabuseki
3
680
メディアアートを〈拡張〉する——器官学と個体化論を手がかりに
_kotobuki_
0
340
AWS Blocksで AIエージェント作れるの知ってます?
kmiya84377
1
170
セキュリティチームは どのコンテナイメージの脆弱性対応を優先すべきか 〜CISA新指針とSCCで作る脆弱性トリアージ〜
swdtkuy
0
340
こんなに変わった! AWSネットワークの常識
shotashiratori
16
12k
From vibe coding to reliable (agentic) development
jcabot
0
270
Agent Routerで作るマルチテナント 推論基盤 #CNDW2026 / Building Multi-Tenant Inference Platform with Agent Router #CNDW2026
everpeace
5
610
SBOM 生成ツールで 2026 Minimum Elements はどこまで満たせるのか
gokken
0
160
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
109
250k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.9k
30 Presentation Tips
portentint
PRO
1
480
Building a Scalable Design System with Sketch
lauravandoore
464
34k
The Language of Interfaces
destraynor
163
27k
Navigating Weather and Climate Data
rabernat
0
600
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
380
We Are The Robots
honzajavorek
0
460
Visualization
eitanlees
153
17k
A better future with KSS
kneath
240
18k