Top Banner
MongoDB and DigitalOcean Jay Gordon Developer Advocate - NYC @jaydestro
55

MongoDB and DigitalOcean Automation with Cloud Manager

Apr 11, 2017

Download

Technology

Jay Gordon
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MongoDB and DigitalOcean Automation with Cloud Manager

MongoDB and DigitalOcean

Jay GordonDeveloper Advocate - NYC@jaydestro

Page 2: MongoDB and DigitalOcean Automation with Cloud Manager

Jay GordonDeveloper 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

Page 3: MongoDB and DigitalOcean Automation with Cloud Manager

Jay GordonDeveloper 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?

Page 4: MongoDB and DigitalOcean Automation with Cloud Manager

Jay GordonDeveloper 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.

Page 5: MongoDB and DigitalOcean Automation with Cloud Manager

The Modern App

• High Concurrency• High Throughput• Low Latency• Real-time analytics • Cost Effective• Zero downtime

Page 6: MongoDB and DigitalOcean Automation with Cloud Manager

Let’s Meet MongoDB

MongoDB is an open-source, distributed document database that provides high performance, high availability, and scaling.

Page 7: MongoDB and DigitalOcean Automation with Cloud Manager

Let’s Meet MongoDBMongoDB was written to make it simple to store data.

No need for rigid schemas.model your data based on your

changing needs

Page 8: MongoDB and DigitalOcean Automation with Cloud Manager

Let’s Meet MongoDB- MongoDB was built for developers to get started

quickly!- Written in C++, C and JavaScript.- Source and binary packages available for download

on mongodb.com/download- Runs on Windows, Linux and MacOS- Affero GPL License

Page 9: MongoDB and DigitalOcean Automation with Cloud Manager

Drivers & Frameworks

Morphia

MEAN Stack

Page 10: MongoDB and DigitalOcean Automation with Cloud Manager

We’re Talking about Documents.

Page 11: MongoDB and DigitalOcean Automation with Cloud Manager

We’re Talking about Documents.

Page 12: MongoDB and DigitalOcean Automation with Cloud Manager

We’re Talking about Documents.

Page 13: MongoDB and DigitalOcean Automation with Cloud Manager

We’re Talking about Documents.

Page 14: MongoDB and DigitalOcean Automation with Cloud Manager

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}

Page 15: MongoDB and DigitalOcean Automation with Cloud Manager

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 arrays

String

Number

Geo-Location

Fields

Fields can be indexed and queried at any level

ORM layer removed – Data is already an object!

Page 16: MongoDB and DigitalOcean Automation with Cloud Manager

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

Page 17: MongoDB and DigitalOcean Automation with Cloud Manager

BSON Storage

- Binary encoding JSON data representation!

- Easier to transfer than text files- Lightweight, transversable, efficient

Page 18: MongoDB and DigitalOcean Automation with Cloud Manager

BSON Storage

Page 19: MongoDB and DigitalOcean Automation with Cloud Manager

Expressive Query Language

Rich Queries Find Paul’s carsFind 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?)

Page 20: MongoDB and DigitalOcean Automation with Cloud Manager
Page 21: MongoDB and DigitalOcean Automation with Cloud Manager

MongoDB 3.4 – Multi-Model Database

DocumentRich JSON Data Structures

Flexible SchemaGlobal Scale

RelationalLeft-Outer Join

ViewsSchema Validation

Key/ValueHorizontal Scale

In-Memory

SearchText SearchMultiple LanguagesFaceted Search

BinariesFiles & MetadataEncrypted

GraphGraph & HierarchicalRecursive Lookups

GeoSpatialGeoJSON2D & 2DSphere

Page 22: MongoDB and DigitalOcean Automation with Cloud Manager

Aggregation PipelineThe 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.

Page 23: MongoDB and DigitalOcean Automation with Cloud Manager
Page 24: MongoDB and DigitalOcean Automation with Cloud Manager

Let’s talk what’s inside the your new MongoDB

cluster.

Page 25: MongoDB and DigitalOcean Automation with Cloud Manager

• Primary• Secondary• Votes and Elections• Arbiters• Hidden, delayed secondaries• Config Servers

What Components Make Up MongoDB?

Page 26: MongoDB and DigitalOcean Automation with Cloud Manager

Replication

PRIMARY

SECONDARY SECONDARY

DRIVER

APPLICATION

Page 27: MongoDB and DigitalOcean Automation with Cloud Manager

Failure of Primary

PRIMARY

SECONDARY SECONDARY

DRIVER

APPLICATION

Page 28: MongoDB and DigitalOcean Automation with Cloud Manager

ELECTION TIME

OFFLINE

SECONDARY

DRIVER

APPLICATION

PRIMARY

Page 29: MongoDB and DigitalOcean Automation with Cloud Manager

WE LIVE!

RECOVERY

SECONDARY

DRIVER

APPLICATION

PRIMARY

Page 30: MongoDB and DigitalOcean Automation with Cloud Manager

Back to Biz

SECONDARY

SECONDARY

DRIVER

APPLICATION

PRIMARY

Page 31: MongoDB and DigitalOcean Automation with Cloud Manager

Sharding

SHARD0

SHARD1

SHARD2

SHARD3

ROUTERmongos DRIVER

APPLICATION

P

S S

CONFIG SERVERS

Page 32: MongoDB and DigitalOcean Automation with Cloud Manager

Sharding & Replication

ROUTERmongos DRIVER

APPLICATION

P

S S

P

S S

P

S S

P

S S

P

S S

CONFIG SERVERS

Page 33: MongoDB and DigitalOcean Automation with Cloud Manager

Helping you deploy in any environment

Control

Cloud Manager Ops Manager MongoDB Atlasdata: on-prem or cloudops: on-prem or cloud

data: on-prem or cloudops: cloud

Fully Managed Cloud

Convenience

Page 34: MongoDB and DigitalOcean Automation with Cloud Manager

Lots of Work, A New Database!

PATCHES

UPGRADES

SECURITY

BACKUPS

RECOVERY

99.999% UPTIME

UPSCALE

DOWNSCALE

Page 35: MongoDB and DigitalOcean Automation with Cloud Manager

MongoDB Cloud Manager

The Easiest Way to Get Started With

DigitalOcean (Ops!)

Page 36: MongoDB and DigitalOcean Automation with Cloud Manager

Example of Web App on DO Network

Cloud Manager data: on-prem or cloud

ops: cloud

Page 37: MongoDB and DigitalOcean Automation with Cloud Manager

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

Page 38: MongoDB and DigitalOcean Automation with Cloud Manager
Page 39: MongoDB and DigitalOcean Automation with Cloud Manager
Page 40: MongoDB and DigitalOcean Automation with Cloud Manager
Page 41: MongoDB and DigitalOcean Automation with Cloud Manager
Page 42: MongoDB and DigitalOcean Automation with Cloud Manager

Configure Private IP Networkroot@mongodb-1gb-nyc2-01:~# /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f110.128.32.63

root@mongodb-1gb-nyc2-02:~# /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f110.128.32.64

root@mongodb-1gb-nyc2-03:~# /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f110.128.32.66

Page 43: MongoDB and DigitalOcean Automation with Cloud Manager

Hosts file or DNSroot@mongodb-1gb-nyc2-01:~# hostname -fmongodb-1gb-nyc2-01

root@mongodb-1gb-nyc2-02:~# hostname -fmongodb-1gb-nyc2-02

root@mongodb-1gb-nyc2-03:~# hostname -fmongodb-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-0110.128.32.64 mongodb-1gb-nyc2-0210.128.32.66 mongodb-1gb-nyc2-03

Page 44: MongoDB and DigitalOcean Automation with Cloud Manager
Page 45: MongoDB and DigitalOcean Automation with Cloud Manager
Page 46: MongoDB and DigitalOcean Automation with Cloud Manager
Page 47: MongoDB and DigitalOcean Automation with Cloud Manager

Automate your install to Droplets

Page 48: MongoDB and DigitalOcean Automation with Cloud Manager

Finalize changes and deploy

Page 49: MongoDB and DigitalOcean Automation with Cloud Manager

Ready for your connection string!

Page 50: MongoDB and DigitalOcean Automation with Cloud Manager

Sophisticated Security Threats

Page 51: MongoDB and DigitalOcean Automation with Cloud Manager

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

Page 52: MongoDB and DigitalOcean Automation with Cloud Manager

Operations Burden

PATCHES

UPGRADES

SECURITY

BACKUPS

RECOVERY

99.999% UPTIME

UPSCALE

DOWNSCALE

PERFORMANCE

UAT

STAGING

MONITORING

ALERTS

PROVISION

CONFIGURE

INSTALL

Page 53: MongoDB and DigitalOcean Automation with Cloud Manager

Join us at MongoDB World 2017June 20-21Chicago, 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

Page 54: MongoDB and DigitalOcean Automation with Cloud Manager
Page 55: MongoDB and DigitalOcean Automation with Cloud Manager

Questions?