SlideShare ist ein Scribd-Unternehmen logo
1 von 33
1 6 J A N U A RY, 2 0 1 8 | H I LT O N
# M D B l o c a l
USING CHANGE STREAMS TO
KEEP UP WITH YOUR DATA
# M D B l o c a l
Alyson Cabral
Alyson Cabral
PRODUCT MANAGER | MONGODB | @ ALY_CABRAL
# M D B l o c a l
“TIME IS MONEY.”
B E N J A M I N F R A N K L I NWA R R E N B U F F E T
# M D B l o c a l
REAL-TIME IS AN EXPECTATION
# M D B l o c a l
MongoDB
Action
Handler
# M D B l o c a l
const changeStream=
db.collection(‘temperature’).watch();
c h a n g e S t r e a m . o n ( ' c h a n g e ' , f u n c t i o n ( c h a n g e ) {
c o n s o l e . l o g ( c h a n g e ) ;
} ) ;
# M D B l o c a l
CHANGE STREAM
CHARACTERISTICS
# M D B l o c a l
5 OPERATION TYPES
INSERT
DELETE
REPLACE
UPDATE
INVALIDATE
# M D B l o c a l
CHANGE STREAMS UTILIZE
COLLECTION ACCESS CONTROLS,
PRESENT A DEFINED API, AND ENABLE
SCALING ACROSS PRIMARIES AND
SECONDARIES.
# M D B l o c a l
TOTAL ORDERING OF CHANGES ACROSS
SHARDS
mongos
3 1
2
Shard 1 Shard 2 Shard 3
# M D B l o c a l
PS
CHANGES ARE DURABLE
P
S
# M D B l o c a l
SP
CHANGE STREAMS ARE RESUMABLE
P
S
{_id: <resumeToken>,
operationType: ‘update’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘room12345’},
updateDescription: {updatedFields: {temperature: 70},
removedFields: [‘humidity’]}
}
var newChangeStream = coll.watch({ resumeAfter: <cachedResumeToken> });
# M D B l o c a l
CHANGE STREAMS UTILIZE THE POWER
OF THE AGGREGATION FRAMEWORK
$match $project $addFields $replaceRoot $redact
var changeStream = coll.watch([{ $match: {$or: [{operationType: 'delete' }, {operationType:'replace'}]}}]);
# M D B l o c a l
1. COLLECTION ACCESS CONTROLS
2. DEFINED API
3. ENABLE SCALING
4. TOTAL ORDERING
5. DURABLE
6. RESUMABLE
7. POWER OF AGGREGATION
# M D B l o c a l
OPERATION TYPES
# M D B l o c a l
DELETEREPLACEUPDATEINVALIDATE5 OPERATION TYPES
{ _id: (resumeToken),
operationType: ‘insert’,
ns: {db: ‘test’, coll: ‘foo’},
documentKey: {userName: ‘alice123’,
_id: ObjectId("58a4eb4a30c75625e00d2820")
},
fullDocument: {_id: ObjectId("58a4eb4a30c75625e00d2820"),
userName: ‘alice123’,
name: ‘Alice’
}
}
INSERT
{_id: (resumeToken),
operationType: ‘delete’,
ns: {db: ‘test’, coll: ‘foo’},
documentKey: {userName: ‘alice123’,
_id: ObjectId("58a4eb4a30c75625e00d2820")
}
}
{_id: (resumeToken),
operationType: ‘replace’,
ns: {db: ‘test’, coll: ‘foo’},
documentKey: {userName: ‘alice123’,
_id: ObjectId("58a4eb4a30c75625e00d2820")
},
fullDocument: {_id: ObjectId("58a4eb4a30c75625e00d2820"),
userName: ‘alice123’,
name: ‘Alice’
}
}
{_id: (resumeToken),
operationType: ‘update’,
ns: {db: ‘test’, coll: ‘foo’},
documentKey: {userName: ‘alice123’,
_id: ObjectId("58a4eb4a30c75625e00d2820")
},
updateDescription: {updatedFields: {email: ‘alice@10gen.com’},
removedFields: [‘phoneNumber’]}
}
{_id: (resumeToken),
operationType: ‘invalidate’,
ns: {db: ‘test’, coll: ‘foo’}}
# M D B l o c a l
{_id: (resumeToken),
operationType: ‘update’,
ns: {db: ‘test’, coll: ‘foo’},
documentKey: {userName: ‘alice123’,
_id: ObjectId("58a4eb4a30c75625e00d2820")},
updateDescription: {updatedFields: {email: ‘alice@10gen.com’},
removedFields: [‘phoneNumber’]}
}
UPDATE
var changeStream = coll.watch({ fullDocument: 'updateLookup' });
UPDATE fullDocument: updateLookup
{_id: (resumeToken),
operationType: ‘update’,
ns: {db: ‘test’, coll: ‘foo’},
documentKey: {userName: ‘alice123’,
_id: ObjectId("58a4eb4a30c75625e00d2820")},
updateDescription: {updatedFields: {email:
‘alice@10gen.com’},
removedFields: [‘phoneNumber’]},
fullDocument: { _id: ObjectId("58a4eb4a30c75625e00d2820"),
name: ‘Alice’,
userName: ‘alice123’,
email: ‘alice@10gen.com’,
team: ‘replication’}
}
# M D B l o c a l
1 . S H A R D K E Y I S U S E D ( B Y T H E M O N G O S ) TO R O U T E
O P E R AT I O N S
2 . _ I D U N I Q U E N E S S I S E N F O R C E D B Y S H A R D
mongos
3 1
2
Shard 1 Shard 2 Shard 3
DEFINING THE documentKey
# M D B l o c a l
BACK TO
THE USE CASE
# M D B l o c a l
# M D B l o c a l
{_id: (resumeToken),
operationType: ‘insert’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘orangeRoom123’
fullDocument: {_id: ‘orangeRoom123’,
temperature: 76,
username: eliot_horowitz }
}
Action Handler
{_id: (resumeToken),
operationType: ‘update’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘greenRoom123’)},
updateDescription: {updatedFields: {temperature: 68}
fullDocument: {_id: ‘greenRoom123’,
temperature: 68,
username: aly_cabral}
}
{_id: (resumeToken),
operationType: ‘insert’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘greenRoom123’},
fullDocument: {_id: ‘greenRoom123’),
temperature: 75,
username: aly_cabral}
}
var changeStream = coll.watch([{
$match: {{ 'fullDocument.temperature': {$gte : 70 }}},
{fullDocument: 'updateLookup' }]);
temperature: 75
username: aly_cabral
# M D B l o c a l
IF YOUR APPLICATION REQUIRES STATE
ALWAYS MATCH ON UNCHANGING
FIELDS
# M D B l o c a l
Action Handler
{_id: (resumeToken),
operationType: ‘replace’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘blueRoom123’},
fullDocument: {_id: ‘blueRoom123’,
temperature: 71,
username: asya_kamsky}
}
var changeStream = coll.watch([{ $match: {{ 'fullDocument.username': ‘aly_cabral’ }}},
{fullDocument: 'updateLookup' }]);
temperature: 75
username: aly_cabral
temperature: 85
username: aly_cabral
{_id: (resumeToken),
operationType: ‘delete’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘blueRoom123’}}
{_id: (resumeToken),
operationType: ‘insert’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘blueRoom123’},
fullDocument: {_id: ‘blueRoom123’,
temperature: 85,
username: aly_cabral}
}
# M D B l o c a l
IF YOUR APPLICATION NEEDS TO NOTIFY ON DELETED
DATA
ALWAYS HANDLE DELETES AND
REPLACES APPROPRIATELY
# M D B l o c a l
var changeStream = coll.watch([{ $match: {
{ $or: [ { 'fullDocument.username': ‘aly_cabral'
}, { operationType: 'delete' },
{ operationType: 'replace' }]}],
{fullDocument: 'updateLookup' });
Insert Update Delete
In the update notification fullDocument: null
updateLookup
{_id: (resumeToken),
operationType: ‘update’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {userName: ‘greenRoom123’},
updateDescription: {updatedFields: {temperature: 78}},
fullDocument: {}
}
# M D B l o c a l
IF YOU NEED TO SEE EVERY CHANGE (EVEN OUTDATED
CHANGES) TO A DOCUMENT
HAVE MATCHING FIELDS IN THE
DOCUMENT KEY
# M D B l o c a l
{_id: (resumeToken),
operationType: ‘insert’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘blueRoom123’,
username: “aly_cabral”},
fullDocument: {_id: ‘blueRoom123’,
temperature: 85,
username: “aly_cabral”}
}
Action Handler
var changeStream = coll.watch([{ $match: {{ ‘documentKey.username’: ‘aly_cabral’ }}},
{fullDocument: 'updateLookup' }]);
temperature: 75
username: aly_cabral
temperature: 85
username: aly_cabral
{_id: (resumeToken),
operationType: ‘delete’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘blueRoom123’,
username: “aly_cabral”)}}
{_id: (resumeToken),
operationType: ‘replace’,
ns: {db: ‘data’, coll: ‘temperature’},
documentKey: {_id: ‘greenRoom123’,
username: ‘aly_cabral’},
fullDocument: {_id: ‘greenRoom123’,
temperature: 71,
username: “asya_kamsky”}
}
# M D B l o c a l
UNDERLYING
TECHNOLOGY
# M D B l o c a l
P
S
S
S
S
# M D B l o c a l
1234
# M D B l o c a l
RESUMABLE
304 270 233 208 201 190
C A C H E D R E S U M E TO K E N : 2 0 8
N E W E S T O L D E S T
D E L E T E D
# M D B l o c a l
304 270 233 208 201 190
C A C H E D R E S U M E TO K E N : 1 9 0
N E W E S T O L D E S T
D E L E T E D
NON-RESUMABLE
# M D B l o c a l
YOU MADE IT!

Weitere ähnliche Inhalte

Was ist angesagt?

#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context LibraryExotel
 
Herding types with Scala macros
Herding types with Scala macrosHerding types with Scala macros
Herding types with Scala macrosMarina Sigaeva
 
New text document
New text documentNew text document
New text documentTam Ngo
 
Py spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comPy spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comLam Hoang
 
Implementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsImplementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsMichele Orselli
 
Cassandra v3.0 at Rakuten meet-up on 12/2/2015
Cassandra v3.0 at Rakuten meet-up on 12/2/2015Cassandra v3.0 at Rakuten meet-up on 12/2/2015
Cassandra v3.0 at Rakuten meet-up on 12/2/2015datastaxjp
 
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid ThemRedux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid ThemAdam Klein
 
Implementing data sync apis for mibile apps @cloudconf
Implementing data sync apis for mibile apps @cloudconfImplementing data sync apis for mibile apps @cloudconf
Implementing data sync apis for mibile apps @cloudconfMichele Orselli
 
Server side data sync for mobile apps with silex
Server side data sync for mobile apps with silexServer side data sync for mobile apps with silex
Server side data sync for mobile apps with silexMichele Orselli
 
オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)Takayuki Goto
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraDeependra Ariyadewa
 
Insert latest articles on blogger
Insert latest articles on bloggerInsert latest articles on blogger
Insert latest articles on bloggerStefano Vinci
 

Was ist angesagt? (20)

Codeofdatabase
CodeofdatabaseCodeofdatabase
Codeofdatabase
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
library(sparkline)
library(sparkline)library(sparkline)
library(sparkline)
 
Rxjs swetugg
Rxjs swetuggRxjs swetugg
Rxjs swetugg
 
Typelevel summit
Typelevel summitTypelevel summit
Typelevel summit
 
Firebase ng2 zurich
Firebase ng2 zurichFirebase ng2 zurich
Firebase ng2 zurich
 
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
 
Herding types with Scala macros
Herding types with Scala macrosHerding types with Scala macros
Herding types with Scala macros
 
New text document
New text documentNew text document
New text document
 
Py spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comPy spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.com
 
Implementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsImplementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile Apps
 
Cassandra v3.0 at Rakuten meet-up on 12/2/2015
Cassandra v3.0 at Rakuten meet-up on 12/2/2015Cassandra v3.0 at Rakuten meet-up on 12/2/2015
Cassandra v3.0 at Rakuten meet-up on 12/2/2015
 
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid ThemRedux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
Redux "Bad" Practices - A List of 13 Bad Practices and How to Avoid Them
 
Angular2 rxjs
Angular2 rxjsAngular2 rxjs
Angular2 rxjs
 
Implementing data sync apis for mibile apps @cloudconf
Implementing data sync apis for mibile apps @cloudconfImplementing data sync apis for mibile apps @cloudconf
Implementing data sync apis for mibile apps @cloudconf
 
Server side data sync for mobile apps with silex
Server side data sync for mobile apps with silexServer side data sync for mobile apps with silex
Server side data sync for mobile apps with silex
 
オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and Cassandra
 
Insert latest articles on blogger
Insert latest articles on bloggerInsert latest articles on blogger
Insert latest articles on blogger
 
Oop assignment 02
Oop assignment 02Oop assignment 02
Oop assignment 02
 

Ähnlich wie SH 1 - SES 7 - Change-Streams-Tel-Aviv.pptx

Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataMongoDB
 
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your DataMongoDB
 
How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6Maxime Beugnet
 
Function Procedure Trigger Partition.pdf
Function Procedure Trigger Partition.pdfFunction Procedure Trigger Partition.pdf
Function Procedure Trigger Partition.pdfSanam Maharjan
 
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptxSH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptxMongoDB
 
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptxSH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptxMongoDB
 
Reactive.architecture.with.Angular
Reactive.architecture.with.AngularReactive.architecture.with.Angular
Reactive.architecture.with.AngularEvan Schultz
 
Oracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesOracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesKim Berg Hansen
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres MonitoringDenish Patel
 
Classic Games Development with Drools
Classic Games Development with DroolsClassic Games Development with Drools
Classic Games Development with DroolsMark Proctor
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS ProgrammersDavid Rodenas
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfrajkumarm401
 
Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片cfc
 

Ähnlich wie SH 1 - SES 7 - Change-Streams-Tel-Aviv.pptx (20)

Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your Data
 
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
 
How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6
 
Function Procedure Trigger Partition.pdf
Function Procedure Trigger Partition.pdfFunction Procedure Trigger Partition.pdf
Function Procedure Trigger Partition.pdf
 
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
 
Grails UI Primer
Grails UI PrimerGrails UI Primer
Grails UI Primer
 
Graphql, REST and Apollo
Graphql, REST and ApolloGraphql, REST and Apollo
Graphql, REST and Apollo
 
Cdc
CdcCdc
Cdc
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptxSH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
 
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptxSH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
SH 1 - SES 3 - 3.6-Overview-Tel-Aviv.pptx
 
Reactive.architecture.with.Angular
Reactive.architecture.with.AngularReactive.architecture.with.Angular
Reactive.architecture.with.Angular
 
Oracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesOracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web Services
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres Monitoring
 
Classic Games Development with Drools
Classic Games Development with DroolsClassic Games Development with Drools
Classic Games Development with Drools
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS Programmers
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdf
 
Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片Contagion的Ruby/Rails投影片
Contagion的Ruby/Rails投影片
 

Mehr von MongoDB

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump StartMongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB
 

Mehr von MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

SH 1 - SES 7 - Change-Streams-Tel-Aviv.pptx

  • 1. 1 6 J A N U A RY, 2 0 1 8 | H I LT O N # M D B l o c a l USING CHANGE STREAMS TO KEEP UP WITH YOUR DATA
  • 2. # M D B l o c a l Alyson Cabral Alyson Cabral PRODUCT MANAGER | MONGODB | @ ALY_CABRAL
  • 3. # M D B l o c a l “TIME IS MONEY.” B E N J A M I N F R A N K L I NWA R R E N B U F F E T
  • 4. # M D B l o c a l REAL-TIME IS AN EXPECTATION
  • 5. # M D B l o c a l MongoDB Action Handler
  • 6. # M D B l o c a l const changeStream= db.collection(‘temperature’).watch(); c h a n g e S t r e a m . o n ( ' c h a n g e ' , f u n c t i o n ( c h a n g e ) { c o n s o l e . l o g ( c h a n g e ) ; } ) ;
  • 7. # M D B l o c a l CHANGE STREAM CHARACTERISTICS
  • 8. # M D B l o c a l 5 OPERATION TYPES INSERT DELETE REPLACE UPDATE INVALIDATE
  • 9. # M D B l o c a l CHANGE STREAMS UTILIZE COLLECTION ACCESS CONTROLS, PRESENT A DEFINED API, AND ENABLE SCALING ACROSS PRIMARIES AND SECONDARIES.
  • 10. # M D B l o c a l TOTAL ORDERING OF CHANGES ACROSS SHARDS mongos 3 1 2 Shard 1 Shard 2 Shard 3
  • 11. # M D B l o c a l PS CHANGES ARE DURABLE P S
  • 12. # M D B l o c a l SP CHANGE STREAMS ARE RESUMABLE P S {_id: <resumeToken>, operationType: ‘update’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘room12345’}, updateDescription: {updatedFields: {temperature: 70}, removedFields: [‘humidity’]} } var newChangeStream = coll.watch({ resumeAfter: <cachedResumeToken> });
  • 13. # M D B l o c a l CHANGE STREAMS UTILIZE THE POWER OF THE AGGREGATION FRAMEWORK $match $project $addFields $replaceRoot $redact var changeStream = coll.watch([{ $match: {$or: [{operationType: 'delete' }, {operationType:'replace'}]}}]);
  • 14. # M D B l o c a l 1. COLLECTION ACCESS CONTROLS 2. DEFINED API 3. ENABLE SCALING 4. TOTAL ORDERING 5. DURABLE 6. RESUMABLE 7. POWER OF AGGREGATION
  • 15. # M D B l o c a l OPERATION TYPES
  • 16. # M D B l o c a l DELETEREPLACEUPDATEINVALIDATE5 OPERATION TYPES { _id: (resumeToken), operationType: ‘insert’, ns: {db: ‘test’, coll: ‘foo’}, documentKey: {userName: ‘alice123’, _id: ObjectId("58a4eb4a30c75625e00d2820") }, fullDocument: {_id: ObjectId("58a4eb4a30c75625e00d2820"), userName: ‘alice123’, name: ‘Alice’ } } INSERT {_id: (resumeToken), operationType: ‘delete’, ns: {db: ‘test’, coll: ‘foo’}, documentKey: {userName: ‘alice123’, _id: ObjectId("58a4eb4a30c75625e00d2820") } } {_id: (resumeToken), operationType: ‘replace’, ns: {db: ‘test’, coll: ‘foo’}, documentKey: {userName: ‘alice123’, _id: ObjectId("58a4eb4a30c75625e00d2820") }, fullDocument: {_id: ObjectId("58a4eb4a30c75625e00d2820"), userName: ‘alice123’, name: ‘Alice’ } } {_id: (resumeToken), operationType: ‘update’, ns: {db: ‘test’, coll: ‘foo’}, documentKey: {userName: ‘alice123’, _id: ObjectId("58a4eb4a30c75625e00d2820") }, updateDescription: {updatedFields: {email: ‘alice@10gen.com’}, removedFields: [‘phoneNumber’]} } {_id: (resumeToken), operationType: ‘invalidate’, ns: {db: ‘test’, coll: ‘foo’}}
  • 17. # M D B l o c a l {_id: (resumeToken), operationType: ‘update’, ns: {db: ‘test’, coll: ‘foo’}, documentKey: {userName: ‘alice123’, _id: ObjectId("58a4eb4a30c75625e00d2820")}, updateDescription: {updatedFields: {email: ‘alice@10gen.com’}, removedFields: [‘phoneNumber’]} } UPDATE var changeStream = coll.watch({ fullDocument: 'updateLookup' }); UPDATE fullDocument: updateLookup {_id: (resumeToken), operationType: ‘update’, ns: {db: ‘test’, coll: ‘foo’}, documentKey: {userName: ‘alice123’, _id: ObjectId("58a4eb4a30c75625e00d2820")}, updateDescription: {updatedFields: {email: ‘alice@10gen.com’}, removedFields: [‘phoneNumber’]}, fullDocument: { _id: ObjectId("58a4eb4a30c75625e00d2820"), name: ‘Alice’, userName: ‘alice123’, email: ‘alice@10gen.com’, team: ‘replication’} }
  • 18. # M D B l o c a l 1 . S H A R D K E Y I S U S E D ( B Y T H E M O N G O S ) TO R O U T E O P E R AT I O N S 2 . _ I D U N I Q U E N E S S I S E N F O R C E D B Y S H A R D mongos 3 1 2 Shard 1 Shard 2 Shard 3 DEFINING THE documentKey
  • 19. # M D B l o c a l BACK TO THE USE CASE
  • 20. # M D B l o c a l
  • 21. # M D B l o c a l {_id: (resumeToken), operationType: ‘insert’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘orangeRoom123’ fullDocument: {_id: ‘orangeRoom123’, temperature: 76, username: eliot_horowitz } } Action Handler {_id: (resumeToken), operationType: ‘update’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘greenRoom123’)}, updateDescription: {updatedFields: {temperature: 68} fullDocument: {_id: ‘greenRoom123’, temperature: 68, username: aly_cabral} } {_id: (resumeToken), operationType: ‘insert’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘greenRoom123’}, fullDocument: {_id: ‘greenRoom123’), temperature: 75, username: aly_cabral} } var changeStream = coll.watch([{ $match: {{ 'fullDocument.temperature': {$gte : 70 }}}, {fullDocument: 'updateLookup' }]); temperature: 75 username: aly_cabral
  • 22. # M D B l o c a l IF YOUR APPLICATION REQUIRES STATE ALWAYS MATCH ON UNCHANGING FIELDS
  • 23. # M D B l o c a l Action Handler {_id: (resumeToken), operationType: ‘replace’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘blueRoom123’}, fullDocument: {_id: ‘blueRoom123’, temperature: 71, username: asya_kamsky} } var changeStream = coll.watch([{ $match: {{ 'fullDocument.username': ‘aly_cabral’ }}}, {fullDocument: 'updateLookup' }]); temperature: 75 username: aly_cabral temperature: 85 username: aly_cabral {_id: (resumeToken), operationType: ‘delete’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘blueRoom123’}} {_id: (resumeToken), operationType: ‘insert’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘blueRoom123’}, fullDocument: {_id: ‘blueRoom123’, temperature: 85, username: aly_cabral} }
  • 24. # M D B l o c a l IF YOUR APPLICATION NEEDS TO NOTIFY ON DELETED DATA ALWAYS HANDLE DELETES AND REPLACES APPROPRIATELY
  • 25. # M D B l o c a l var changeStream = coll.watch([{ $match: { { $or: [ { 'fullDocument.username': ‘aly_cabral' }, { operationType: 'delete' }, { operationType: 'replace' }]}], {fullDocument: 'updateLookup' }); Insert Update Delete In the update notification fullDocument: null updateLookup {_id: (resumeToken), operationType: ‘update’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {userName: ‘greenRoom123’}, updateDescription: {updatedFields: {temperature: 78}}, fullDocument: {} }
  • 26. # M D B l o c a l IF YOU NEED TO SEE EVERY CHANGE (EVEN OUTDATED CHANGES) TO A DOCUMENT HAVE MATCHING FIELDS IN THE DOCUMENT KEY
  • 27. # M D B l o c a l {_id: (resumeToken), operationType: ‘insert’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘blueRoom123’, username: “aly_cabral”}, fullDocument: {_id: ‘blueRoom123’, temperature: 85, username: “aly_cabral”} } Action Handler var changeStream = coll.watch([{ $match: {{ ‘documentKey.username’: ‘aly_cabral’ }}}, {fullDocument: 'updateLookup' }]); temperature: 75 username: aly_cabral temperature: 85 username: aly_cabral {_id: (resumeToken), operationType: ‘delete’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘blueRoom123’, username: “aly_cabral”)}} {_id: (resumeToken), operationType: ‘replace’, ns: {db: ‘data’, coll: ‘temperature’}, documentKey: {_id: ‘greenRoom123’, username: ‘aly_cabral’}, fullDocument: {_id: ‘greenRoom123’, temperature: 71, username: “asya_kamsky”} }
  • 28. # M D B l o c a l UNDERLYING TECHNOLOGY
  • 29. # M D B l o c a l P S S S S
  • 30. # M D B l o c a l 1234
  • 31. # M D B l o c a l RESUMABLE 304 270 233 208 201 190 C A C H E D R E S U M E TO K E N : 2 0 8 N E W E S T O L D E S T D E L E T E D
  • 32. # M D B l o c a l 304 270 233 208 201 190 C A C H E D R E S U M E TO K E N : 1 9 0 N E W E S T O L D E S T D E L E T E D NON-RESUMABLE
  • 33. # M D B l o c a l YOU MADE IT!

Hinweis der Redaktion

  1. Hey guys, thank you all for being here. I know it can get a little bit rough at this time at a full day event, so I appreciate you guys sticking with me. I promise you won’t regret it. Today, I have the privilege of introducing Change Streams, a new feature in MongoDB 3.6 (being released later this year)
  2. Before we get into the fun stuff, I have a little story. I was at a trivia night recently and one of the questions was who popularized the term “time is money”. My guess, naturally, was Warren Buffet as the was the famous business man the popped into my head at the time. Well, turns out I was only a couple centuries off. The real answer is Benjamin Franklin. Benjamin Franklin popularized the term time is money in the1700s. What a fascinating phrase it feels weirdly modern doesn’t it? I think it’s because this phrase has never rang more true than it is today. With the evolution of technology, and enabled by these innovations, each of us is able to do more and more in every second. We live in an era where we can catch up on the lastest news, socialize with our friends, get a date for the evening -- all in the two minutes it takes for us to use the restroom. While that is a silly example, we have become accustomed to doing and reacting to things as quickly as possible.
  3. As the builders we are in this room, we’ve realized that real-time is no longer this flashy nice-to-have in our applications. It is our users expectation. Whether those users are our bosses looking at real-time monitoring dashboard or the general public wanting updates on their food deliveries precise location. We at MongoDB sought out to make it easier for you to rise to the high expectations your users have. And with that, in MongoDB 3.6 we are introducing Change Streams. In this talk, I will give you a simple definition of what change streams are and the power they possess. Then we will go into some one the charactertics change streams have. Finally, we will discuss how you can avoid some potential pitfalls.
  4. So let’s start with a simple definition. Change streams allow you to watch all the changes against a given collection. So, when you open change streams against a collection you will see all of the changes applied to documents that belong to that collection. On each change a listening application will be notified with a document describing the change. Imagine this scenario, I have a smart thermometer within my apartment. Every second it inserts a document into MongoDB with temperature data. Change streams can then notify any listening application to every change in my temperature collection. So as the thermometer inserts new data, change streams will inform my listening action handler. In this case, the action handler is an application I built to turn on a fan every time the temperature goes above 70 degrees. Don’t let the simplicity of this example fool you, this concept can be applied to back-office management applications to end user applications. Change streams are extremely powerful
  5. So, this slide is to show you how incredibly simple it is to implement change streams in your application. This example happens to be in node. Here, I am defining a change stream. Then starting it where every change gets printed out. It’s extremely simple and incredibly powerful. With change stream, you get a real-time feed of the changes to your data, enabling your application to react to these changes immediately.
  6. Now we are going to move into some of the characteristics of change streams.
  7. Now we are going to move into some of the characteristics of change streams.
  8. The oplog is an internal mechanism that tracks all changes across the entire cluster, whether they are data or system changes. The