MongoDB and
DigitalOcean
Jay Gordon
Developer Advocate - NYC
@jaydestro
Jay Gordon
Developer Advocate - NYC
@jaydestro
{
"name" : "Jay Gordon",
"what" : Dev Advocate,
"former roles" : [
{ "title" : "SysAdmin",
"company": "BuzzFeed"
},
{ "title" : "Platform Engineer",
"company" : "DigitalOcean"
}
Area Man Talks About Software
Jay Gordon
Developer Advocate - NYC
@jaydestro
GET TO THE POINT.
Topics:
- Introducing MongoDB
- What’s under the hood?
- What makes up MongoDB?
- How can I configure MongoDB
with DO?
Jay Gordon
Developer Advocate - NYC
@jaydestro
GET TO THE POINT.
Not gonna:
- Use a silly analogy
about MongoDB and my
favorite sports
personality.
- Badmouth other DBs.
- Code live.
The Modern App
• High Concurrency
• High Throughput
• Low Latency
• Real-time analytics
• Cost Effective
• Zero downtime
Let’s Meet MongoDB
Let’s Meet MongoDB
Let’s Meet MongoDB
Drivers & Frameworks
Morphia
MEAN Stack
We’re Talking about Documents.
We’re Talking about Documents.
We’re Talking about Documents.
We’re Talking about Documents.
Your data is stored in JSON Style
game {
player_one: PlayerID,
player_two: PlayerID,
moves [ { token: <moveToken1>, ts: timestamp1 }, { token:
<moveToken2>, ts: timestamp2 ... ],
game_parameters: { param1 : v, param2 : v, ... },
start_time: ts,
end_time: ts,
state: <state>, // in_play, mate, resign, draw
winner: W || B || D
}
Documents are Rich Data Structures
{
first_name: ‘Paul’,
surname: ‘Miller’,
cell: 447557505611,
city: ‘London’,
location: [45.123,47.232],
Profession: [‘banking’, ‘finance’, ‘trader’],
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
]
}
Fields can contain an array
of sub-documents
Typed field values
Fields can contain arraysFields
Fields can be indexed and
queried at any level
ORM layer removed – Data is
already an object!
Documents are Flexible
{
sku: ‘PAINTZXC123’,
product_name: ‘Acme Paint’,
color: [‘Red’, ‘Green’],
size_oz: [8, 32],
finish: [‘satin’, ‘eggshell’]
}
{
sku: ‘TSHRTASD43546’,
product_name: ‘T-shirt’,
size: [‘S’, ‘M’, ‘L’, ‘XL’],
color: [‘Heather Gray’ … ],
material: ‘100% cotton’,
wash: ‘cold’,
dry: ‘tumble dry low’
}
{
sku: ‘CYCLBVCX6543’,
product_name: ‘Mountain Bike’,
brake_style: ‘mechanical disc’,
color: ‘grey’,
frame_material: ‘aluminum’,
no_speeds: 21,
package_height: ‘7.5x32.9x55’,
weight_lbs: 44.05,
suspension_type: ‘dual’,
wheel_size_in: 26
}
Documents in the same product catalog collection in MongoDB
BSON Storage
BSON Storage
Expressive Query Language
Rich Queries
Find Paul’s cars
Find everybody in London with a car between 1970 and 1980
Geospatial Find all of the car owners within 5km of Trafalgar Sq.
Text Search Find all the cars described as having leather seats
Aggregation Calculate the average value of Paul’s car collection
Map Reduce
What is the ownership pattern of colors by geography over time
(is purple trending in China?)
MongoDB 3.4 – Multi-Model Database
Document
Rich JSON Data Structures
Flexible Schema
Global Scale
Relational
Left-Outer Join
Views
Schema Validation
Key/Value
Horizontal Scale
In-Memory
Search
Text Search
Multiple Languages
Faceted Search
Binaries
Files & Metadata
Encrypted
Graph
Graph & Hierarchical
Recursive Lookups
GeoSpatial
GeoJSON
2D & 2DSphere
Aggregation Pipeline
The aggregation pipeline is a
framework for data aggregation
modeled on the concept of data
processing pipelines. Documents enter
a multi-stage pipeline that transforms
the documents into aggregated
results.
Let’s talk what’s
inside the your new
MongoDB cluster.
• Primary
• Secondary
• Votes and Elections
• Arbiters
• Hidden, delayed secondaries
• Config Servers
What Components Make Up MongoDB?
Replication
PRIMARY
SECONDARY SECONDARY
DRIVER
APPLICATION
Failure of Primary
PRIMARY
SECONDARY SECONDARY
DRIVER
APPLICATION
ELECTION TIME
OFFLINE
SECONDARY
DRIVER
APPLICATION
PRIMARY
WE LIVE!
RECOVERY
SECONDARY
DRIVER
APPLICATION
PRIMARY
Back to Biz
SECONDARY
SECONDARY
DRIVER
APPLICATION
PRIMARY
Sharding
SHARD
0
SHARD
1
SHARD
2
SHARD
3
ROUTER
mongos
DRIVER
APPLICATION
P
S S
CONFIG SERVERS
Sharding & Replication
ROUTER
mongos
DRIVER
APPLICATION
P
S S
P
S S
P
S S
P
S S
P
S S
CONFIG SERVERS
Helping you deploy in any environment
Control
Cloud ManagerOps Manager MongoDB Atlas
data: on-prem or cloud
ops: on-prem or cloud
data: on-prem or cloud
ops: cloud
Fully Managed Cloud
Convenience
Lots of Work, A New Database!
PATCHES
UPGRADES
SECURITY
BACKUPS
RECOVERY
99.999% UPTIME
UPSCALE
DOWNSCALE
MongoDB Cloud
Manager
The Easiest Way to
Get Started With
DigitalOcean (Ops!)
Example of Web App on DO Network
Cloud Manager
data: on-prem or cloud
ops: cloud
Example of Web App on DO Network
Cloud Manager
data: on-prem or cloud
ops: cloud
MongoDB –
Three droplet
cluster.
NodeJS–
Two droplet web app.
DigitalOcean -
Load Balancer
Configure Private IP Network
root@mongodb-1gb-nyc2-01:~# /sbin/ifconfig
eth1 | grep 'inet addr:' | cut -d: -f2| cut
-d' ' -f1
10.128.32.63
root@mongodb-1gb-nyc2-02:~# /sbin/ifconfig
eth1 | grep 'inet addr:' | cut -d: -f2| cut
-d' ' -f1
10.128.32.64
root@mongodb-1gb-nyc2-03:~# /sbin/ifconfig
eth1 | grep 'inet addr:' | cut -d: -f2| cut
-d' ' -f1
10.128.32.66
Hosts file or DNS
root@mongodb-1gb-nyc2-01:~# hostname -f
mongodb-1gb-nyc2-01
root@mongodb-1gb-nyc2-02:~# hostname -f
mongodb-1gb-nyc2-02
root@mongodb-1gb-nyc2-03:~# hostname -f
mongodb-1gb-nyc2-03
Create hosts file entry for each site and then enter it into
each server’s /etc/hosts/ file:
10.128.32.63 mongodb-1gb-nyc2-01
10.128.32.64 mongodb-1gb-nyc2-02
10.128.32.66 mongodb-1gb-nyc2-03
Automate your install to Droplets
Finalize changes and deploy
Ready for your connection string!
Sophisticated Security Threats
Continuous Backup / Point-in-time Restore
Under the hood
● MongoDB Cloud Manager continuously backs up your data,
ensuring your backups are typically just a few seconds behind the
operational system
● Point-in-time backup of replica sets and consistent, cluster-wide
snapshots of sharded clusters. With MongoDB Cloud Manager,
you can easily and safely restore to precisely the moment you
need
● Compression and block-level deduplication technology keeps
your backup processes as efficient as possible
● Backups are securely stored in North America and Europe. For
location flexibility of your backup data, you can utilize MongoDB’s
mongodump / mongorestore tools
Operations Burden
PATCHES
UPGRADES
SECURITY
BACKUPS
RECOVERY
99.999% UPTIME
UPSCALE
DOWNSCALE
PERFORMANCE
UAT
STAGING
MONITORING
ALERTS
PROVISION
CONFIGURE
INSTALL
Join us at MongoDB World 2017
June 20-21
Chicago, IL
Bringing together 3000 developers, architects, IT professionals
and executive decision makers, MongoDB World is the foremost
conference dedicated to the database for giant ideas.
www.mongodb.com/events/mongodb-world-2017
25% Discount with JayGordon25
MongoDB and DigitalOcean Automation with Cloud Manager
MongoDB and DigitalOcean Automation with Cloud Manager

MongoDB and DigitalOcean Automation with Cloud Manager

  • 1.
  • 2.
    Jay Gordon Developer Advocate- NYC @jaydestro { "name" : "Jay Gordon", "what" : Dev Advocate, "former roles" : [ { "title" : "SysAdmin", "company": "BuzzFeed" }, { "title" : "Platform Engineer", "company" : "DigitalOcean" } Area Man Talks About Software
  • 3.
    Jay Gordon Developer Advocate- NYC @jaydestro GET TO THE POINT. Topics: - Introducing MongoDB - What’s under the hood? - What makes up MongoDB? - How can I configure MongoDB with DO?
  • 4.
    Jay Gordon Developer Advocate- NYC @jaydestro GET TO THE POINT. Not gonna: - Use a silly analogy about MongoDB and my favorite sports personality. - Badmouth other DBs. - Code live.
  • 5.
    The Modern App •High Concurrency • High Throughput • Low Latency • Real-time analytics • Cost Effective • Zero downtime
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
    Your data isstored in JSON Style game { player_one: PlayerID, player_two: PlayerID, moves [ { token: <moveToken1>, ts: timestamp1 }, { token: <moveToken2>, ts: timestamp2 ... ], game_parameters: { param1 : v, param2 : v, ... }, start_time: ts, end_time: ts, state: <state>, // in_play, mate, resign, draw winner: W || B || D }
  • 15.
    Documents are RichData Structures { first_name: ‘Paul’, surname: ‘Miller’, cell: 447557505611, city: ‘London’, location: [45.123,47.232], Profession: [‘banking’, ‘finance’, ‘trader’], cars: [ { model: ‘Bentley’, year: 1973, value: 100000, … }, { model: ‘Rolls Royce’, year: 1965, value: 330000, … } ] } Fields can contain an array of sub-documents Typed field values Fields can contain arraysFields Fields can be indexed and queried at any level ORM layer removed – Data is already an object!
  • 16.
    Documents are Flexible { sku:‘PAINTZXC123’, product_name: ‘Acme Paint’, color: [‘Red’, ‘Green’], size_oz: [8, 32], finish: [‘satin’, ‘eggshell’] } { sku: ‘TSHRTASD43546’, product_name: ‘T-shirt’, size: [‘S’, ‘M’, ‘L’, ‘XL’], color: [‘Heather Gray’ … ], material: ‘100% cotton’, wash: ‘cold’, dry: ‘tumble dry low’ } { sku: ‘CYCLBVCX6543’, product_name: ‘Mountain Bike’, brake_style: ‘mechanical disc’, color: ‘grey’, frame_material: ‘aluminum’, no_speeds: 21, package_height: ‘7.5x32.9x55’, weight_lbs: 44.05, suspension_type: ‘dual’, wheel_size_in: 26 } Documents in the same product catalog collection in MongoDB
  • 17.
  • 18.
  • 19.
    Expressive Query Language RichQueries Find Paul’s cars Find everybody in London with a car between 1970 and 1980 Geospatial Find all of the car owners within 5km of Trafalgar Sq. Text Search Find all the cars described as having leather seats Aggregation Calculate the average value of Paul’s car collection Map Reduce What is the ownership pattern of colors by geography over time (is purple trending in China?)
  • 21.
    MongoDB 3.4 –Multi-Model Database Document Rich JSON Data Structures Flexible Schema Global Scale Relational Left-Outer Join Views Schema Validation Key/Value Horizontal Scale In-Memory Search Text Search Multiple Languages Faceted Search Binaries Files & Metadata Encrypted Graph Graph & Hierarchical Recursive Lookups GeoSpatial GeoJSON 2D & 2DSphere
  • 22.
    Aggregation Pipeline The aggregationpipeline is a framework for data aggregation modeled on the concept of data processing pipelines. Documents enter a multi-stage pipeline that transforms the documents into aggregated results.
  • 24.
    Let’s talk what’s insidethe your new MongoDB cluster.
  • 25.
    • Primary • Secondary •Votes and Elections • Arbiters • Hidden, delayed secondaries • Config Servers What Components Make Up MongoDB?
  • 26.
  • 27.
    Failure of Primary PRIMARY SECONDARYSECONDARY DRIVER APPLICATION
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
    Sharding & Replication ROUTER mongos DRIVER APPLICATION P SS P S S P S S P S S P S S CONFIG SERVERS
  • 33.
    Helping you deployin any environment Control Cloud ManagerOps Manager MongoDB Atlas data: on-prem or cloud ops: on-prem or cloud data: on-prem or cloud ops: cloud Fully Managed Cloud Convenience
  • 34.
    Lots of Work,A New Database! PATCHES UPGRADES SECURITY BACKUPS RECOVERY 99.999% UPTIME UPSCALE DOWNSCALE
  • 35.
    MongoDB Cloud Manager The EasiestWay to Get Started With DigitalOcean (Ops!)
  • 36.
    Example of WebApp on DO Network Cloud Manager data: on-prem or cloud ops: cloud
  • 37.
    Example of WebApp on DO Network Cloud Manager data: on-prem or cloud ops: cloud MongoDB – Three droplet cluster. NodeJS– Two droplet web app. DigitalOcean - Load Balancer
  • 42.
    Configure Private IPNetwork root@mongodb-1gb-nyc2-01:~# /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f1 10.128.32.63 root@mongodb-1gb-nyc2-02:~# /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f1 10.128.32.64 root@mongodb-1gb-nyc2-03:~# /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f1 10.128.32.66
  • 43.
    Hosts file orDNS root@mongodb-1gb-nyc2-01:~# hostname -f mongodb-1gb-nyc2-01 root@mongodb-1gb-nyc2-02:~# hostname -f mongodb-1gb-nyc2-02 root@mongodb-1gb-nyc2-03:~# hostname -f mongodb-1gb-nyc2-03 Create hosts file entry for each site and then enter it into each server’s /etc/hosts/ file: 10.128.32.63 mongodb-1gb-nyc2-01 10.128.32.64 mongodb-1gb-nyc2-02 10.128.32.66 mongodb-1gb-nyc2-03
  • 47.
  • 48.
  • 49.
    Ready for yourconnection string!
  • 50.
  • 51.
    Continuous Backup /Point-in-time Restore Under the hood ● MongoDB Cloud Manager continuously backs up your data, ensuring your backups are typically just a few seconds behind the operational system ● Point-in-time backup of replica sets and consistent, cluster-wide snapshots of sharded clusters. With MongoDB Cloud Manager, you can easily and safely restore to precisely the moment you need ● Compression and block-level deduplication technology keeps your backup processes as efficient as possible ● Backups are securely stored in North America and Europe. For location flexibility of your backup data, you can utilize MongoDB’s mongodump / mongorestore tools
  • 52.
  • 53.
    Join us atMongoDB World 2017 June 20-21 Chicago, IL Bringing together 3000 developers, architects, IT professionals and executive decision makers, MongoDB World is the foremost conference dedicated to the database for giant ideas. www.mongodb.com/events/mongodb-world-2017 25% Discount with JayGordon25