MongoDB Stitch is a serverless platform designed to help you easily and securely build an application on top of MongoDB Atlas. It lets developers focus on building applications rather than on managing data manipulation code, service integration, or backend infrastructure. MongoDB Stitch also makes it simple to respond to backend changes immediately, allowing you to simplify client side code and build complex flows more easily. This talk will cover ways that MongoDB Stitch helps you respond to changes in your database and take your applications to the next level.
9. #MDBlocal
Intelligent Operational Data Platform
Best way to work
with data
Intelligently put data
where you want it
Freedom to run
anywhere
● MongoDB Stitch
● MongoDB Server 4.0
● MongoDB Compass
● MongoDB Charts
● MongoDB Mobile
● MongoDB Server 4.0
● MongoDB Atlas
● Ops Manager 4.0
● Free Cloud Monitoring
10. #MDBlocal
The evolution of MongoDB
3.0 3.2
Document Validation
$lookup
Fast Failover
Simpler Scalability
Aggregation ++
Encryption At Rest
In-Memory Storage Engine
BI Connector
MongoDB Compass
APM Integration
Profiler Visualization
Auto Index Builds
Backups to File System
Doc-Level
Concurrency
Compression
Storage Engine API
≤50 replicas
Auditing ++
Ops Manager
Linearizable reads
Intra-cluster compression
Views
Log Redaction
Linearizable Reads
Graph Processing
Decimal
Collations
Faceted Navigation
Zones ++
Aggregation ++
Auto-balancing ++
ARM, Power, zSeries
BI & Spark Connectors ++
Compass ++
Hardware Monitoring
Server Pool
LDAP Authorization
Encrypted Backups
Cloud Foundry Integration
3.4 3.6
Change Streams
Retryable Writes
Expressive Array Updates
Query Expressivity
Causal Consistency
Consistent Sharded Sec. Reads
Compass Community
Ops Manager ++
Query Advisor
Schema Validation
End to End Compression
IP Whitelisting
Default Bind to Localhost
Sessions
WiredTiger 1m+ Collections
MongoDB BI Connector ++
Expressive $lookUp
R Driver
Atlas Cross Region Replication
Atlas Auto Storage Scaling
4.0
Multi-Document ACID Transactions
Atlas Global Sharding
Atlas HIPAA
Atlas LDAP
Atlas Audit
Atlas Encrypted Storage Engine
Atlas AWS Backup Snapshots
Snapshot Reads
Agg Pipeline Type Conversions
40% Faster Shard Migrations
Non-Blocking Secondary Reads
SHA-2
TLS 1.1+
Compass Agg Pipeline Builder
Compass Export to Code
Charts Beta
Monitoring Cloud Service
Ops Manager K8s & OpenShift
MongoDB Stitch GA
MongoDB Mobile (Private Beta)
11. #MDBlocal
“We set out to build a database that we would want to use, so that
whenever developers wanted to build an application, they could
focus on the application, not on working around the database.”
- Eliot Horowitz
12. #MDBlocal
Stitch Functions
Stitch is a collection of servers that
process application requests
Requests:
• Single actions for Database or Services
• Or executing a Stitch Function
• Integrated with Stitch’s rules
Functions:
• Scalable, hosted JavaScript (ES6) Functions
• Integrated with application context
• User, Request, Services, Values, etc.
13. #MDBlocal
MongoDB Query Language + Native DriversIntegrated Rules
Functions3rd Party Services
Native SDKs (JavaScript, Android, iOS)
Rest API
19. #MDBlocal
When do we want functions to execute?
AUTHENTICATION
WEBHOOK/
INTEGRATION
DATABASE EVENTS
3 Contexts Where Functions
Execute
1
2
3
20. #MDBlocal
When do we want functions to execute?
client.executeFunction(…)client.loginWithCredential(…)
AUTHENTICATION
WEBHOOK/
INTEGRATION
DATABASE EVENTS
1
2
3
21. #MDBlocal
When do we want functions to execute?
Incoming Webhooks
(HTTP, Twilio, Github)
AUTHENTICATION
WEBHOOK/
INTEGRATION
DATABASE EVENTS
1
2
3
22. #MDBlocal
When do we want functions to execute?
Database Events
Collection.insertOne(…)
AUTHENTICATION
WEBHOOK/
INTEGRATION
DATABASE EVENTS
1
2
3
26. #MDBlocal
OPLOGOPLOG OPLOG
Application
W
db.users.insert({,,,})
PRIMARY SECONDARY SECONDARY
db.users.insert({,,,})
A
C
K
db.users.insert({,,,})
W
db.users.update({,,,}) db.users.update({,,,})
A
C
K
db.users.update({,,,})
Monitor
R R
If (insert) {
aws.s3.insertObject(…);
}
Before ChangeStreams and Triggers
TAILING THE OPLOG
32. #MDBlocal
Adding Triggers to Stitch
Reduce Time to Market
Functions as a Service: No waiting on
infrastructure
Reduce boilerplate: Save code
Cross-Platform: Develop once
Existing Apps Untouched: No reverse-
engineering
Reduce Ops costs
Serverless: Zero wasted capacity
Payment: No up-front cost
Capacity on Demand: No need to over-
provision in advance
Secure by Default: Less operational effort
Reduce Dev Effort
Backend Integration Built in: No generic
backend code
HA & Scalability Built in: Hard and time
consuming to build Orchestrate Services:
Reuse what's out there
Faster Cheaper Easier
33. #MDBlocal
Event Driven Life-cycle
Pending SucceededOwned
Failed Dead
Event is …
Waiting for a ConsumerAttempting ExecutionCompletedAwaiting RetriesRe-Attempting ExecutionUnable to Execute
(Trigger Disabled)
38. #MDBlocal
What is the Swagstore
Standard Retail Store:
• Browse Items
• Add items to cart
• Checkout
• Request Notification for Restock
Additional Features:
• Update/text on item re-stock
• Shipping text/e-mail notification
Stitch Features
• Functions
• Triggers
• 3rd Party Services
43. #MDBlocal
AUTHENTICATION
BROWSE
SELECT ITEM
IN
STOCK?
CART
CHECKOUT
UPDATE NOTIFY
Initialization
• Before we leverage any features of Stitch,
we must initialize our API with the Stitch
App Key
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import registerServiceWorker from './registerServiceWorker'
import { BrowserRouter } from 'react-router-dom'
import { StitchClientFactory } from 'mongodb-stitch'
const appId = 'ecommercechatbot-glwkl'
let stitchClientPromise = StitchClientFactory.create(appId)
stitchClientPromise.then(stitchClient => {
let db = stitchClient.service('mongodb', 'mongodb-
atlas').db('swagstore')
let props = { stitchClient, db }
ReactDOM.render(
<BrowserRouter>
<App {...props} />
</BrowserRouter>,
document.getElementById('root')
)
registerServiceWorker()
})
54. #MDBlocal
Event Subscriptions
in App Structure
• Event Subscriptions are a
top-level Stitch asset
• Can be constructed in the UI
or with the CLI
55. #MDBlocal
Event Subscriptions
in App Structure
• Event Subscriptions are a
top-level Stitch asset
• Can be constructed in the UI
or with the CLI
56. #MDBlocal
Change Streams Future Work
• Non-Atlas/Multiple Application per Application
• Events that span Multiple MongoDB Instances
• Timed Events
• Execute on a certain Interval
• Execute at a given time
• For now, can use Webhooks with CRON service
58. #MDBlocal
What do change events look like?
Event Subscription (Trigger) Event Source (Actual event document)
59. #MDBlocal
Example Trigger
Name of the Trigger
Type: DATABASE, AUTHENTICATION
Type of Operation to Trigger
Database
Collection
Match Criteria
Full Document or Partial
Function to be called on Trigger