webinar: mongodb and polyglot persistence architecture

59
Polyglot Persistence { Name: ‘Bryan Reinero’, Title: ‘Developer Advocate’, Twitter: ‘@blimpyacht’, Email: [email protected] ’ }

Upload: mongodb

Post on 10-Aug-2015

1.277 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Webinar: MongoDB and Polyglot Persistence Architecture

Polyglot Persistence

{ Name: ‘Bryan Reinero’,

Title: ‘Developer Advocate’,

Twitter: ‘@blimpyacht’,

Email: ‘[email protected]’ }

Page 2: Webinar: MongoDB and Polyglot Persistence Architecture

What is the Polyglots?

• Using multiple Database Technologies in a Given Application

• Using the right tool for the right job

Page 3: Webinar: MongoDB and Polyglot Persistence Architecture

What is the Polyglots?

• Using multiple Database Technologies in a Given Application

• Using the right tool for the right job

Derived from “polyglot programming”. Applications programmed from a mix of languages.

Page 4: Webinar: MongoDB and Polyglot Persistence Architecture

Why is the Polyglots?

• Relational has been the dominant model• Higher performance requirements• Increasingly large datasets• Use of IaaS and commodity hardware

Page 5: Webinar: MongoDB and Polyglot Persistence Architecture

Vertical Scaling

Page 6: Webinar: MongoDB and Polyglot Persistence Architecture

Horizontal Scaling

Page 7: Webinar: MongoDB and Polyglot Persistence Architecture

7

Availability

http://avstop.com/ac/flighttrainghandbook/imagel4b.jpg

Page 8: Webinar: MongoDB and Polyglot Persistence Architecture

8

Availability

http://avstop.com/ac/flighttrainghandbook/imagel4b.jpg

Requirements• Maximize uptime• Minimize time to recover

Page 9: Webinar: MongoDB and Polyglot Persistence Architecture

9

Availability

http://avstop.com/ac/flighttrainghandbook/imagel4b.jpg

Requirements• Maximize uptime• Minimize time to recover

Hardware failures

Network partitions

Data center failures

Maintenance Operations

Page 10: Webinar: MongoDB and Polyglot Persistence Architecture

10

Availability

http://avstop.com/ac/flighttrainghandbook/imagel4b.jpg

Business critical systems require automatic fault detection and fail over

Page 11: Webinar: MongoDB and Polyglot Persistence Architecture

11

Variant Data Models

58842

45647

52320

88237

78932

Key-Value Store

Eratosthenes

Democritus

Hypatia

Shemp

Euripides

ID Name

Page 12: Webinar: MongoDB and Polyglot Persistence Architecture

12

Variant Data Models

Eratosthenes

Democritus

Hypatia

Shemp

Euripides

Graph Databases

Page 13: Webinar: MongoDB and Polyglot Persistence Architecture

13

Variant Data Models

Document Databases{

maker : ”Agusta",type : sportbike,rake : 7,trail : 3.93,engine : {

type : "internal combustion",layout : "inline"cylinders : 4,displacement : 750,

},transmission : {

type : "cassette",speeds : 6,pattern : "sequential”,ratios : [ 2.7, 1.94, 1.34, 1,

0.83, 0.64 ]}

}

Page 14: Webinar: MongoDB and Polyglot Persistence Architecture

The Goals of Normalization

• Model data an understandable form

• Reduce fact redundancy and data inconsistency

• Enforce integrity constraints

Page 15: Webinar: MongoDB and Polyglot Persistence Architecture

Polyglot Persistence

ApplicationServers MongoDB

RDBMS

Key / Value

Session Data, Shopping Carts

Product Catalog,User Accounts,Domain Objects

PaymentSystems,Reporting

GraphSocial Data,Recommendations

Page 16: Webinar: MongoDB and Polyglot Persistence Architecture

Polyglot Persistence

ApplicationServers MongoDB

RDBMS

Key / Value

Session Data, Shopping Carts

Product Catalog,User Accounts,Domain Objects

PaymentSystems,Reporting

GraphSocial Data,Recommendations

Page 17: Webinar: MongoDB and Polyglot Persistence Architecture

What are your requirements?

• Availability• Scalability• Performance• Access Patterns• Data Model

Page 18: Webinar: MongoDB and Polyglot Persistence Architecture

18

Key Value Stores

58842

45647

52320

88237

78932

Used for• Session data• Cookies• Shopping carts

Eratosthenes

Democritus

Hypatia

Shemp

Euripides

ID Name

Page 19: Webinar: MongoDB and Polyglot Persistence Architecture

19

Key Value Stores

58842

45647

52320

88237

78932

• Fast, if in memory• Single access pattern• Complex data parsed

in client

Eratosthenes

Democritus

Hypatia

Shemp

Euripides

ID Name

Page 20: Webinar: MongoDB and Polyglot Persistence Architecture

Key Value Store

“{maker : ‘Agusta’,type : sportbike,rake : 7,trail : 3.93,engine : {

type : ‘internal combustion’,layout : ‘inline’,cylinders : 4,displacement : 750,

},transmission : {

type : ‘cassette’,speeds : 6,pattern : ‘sequential’,ratios : [ 2.7, 1.94, 1.34, 1, 0.83, 0.64 ]

}}”

Page 21: Webinar: MongoDB and Polyglot Persistence Architecture

MongoDB

{ _id: 78234974,maker : ”Agusta",type : sportbike,rake : 7,trail : 3.93,engine : {

type : "internal combustion",layout : "inline"cylinders : 4,displacement : 750,

},transmission : {

type : "cassette",speeds : 6,pattern : "sequential”,ratios : [ 2.7, 1.94, 1.34, 1, 0.83, 0.64 ]

}}

Self Defining Schema

Page 22: Webinar: MongoDB and Polyglot Persistence Architecture

MongoDB

{ _id: 78234974,maker : ”Agusta",type : sportbike,rake : 7,trail : 3.93,engine : {

type : "internal combustion",layout : "inline"cylinders : 4,displacement : 750,

},transmission : {

type : "cassette",speeds : 6,pattern : "sequential”,ratios : [ 2.7, 1.94, 1.34, 1, 0.83, 0.64 ]

}}

Self Defining SchemaNested Objects

Page 23: Webinar: MongoDB and Polyglot Persistence Architecture

MongoDB

{ _id: 78234974,maker : ”Agusta",type : sportbike,rake : 7,trail : 3.93,engine : {

type : "internal combustion",layout : "inline"cylinders : 4,displacement : 750,

},transmission : {

type : "cassette",speeds : 6,pattern : "sequential”,ratios : [ 2.7, 1.94, 1.34, 1, 0.83, 0.64 ]

}}

Self Defining SchemaNested ObjectsArray types

Page 24: Webinar: MongoDB and Polyglot Persistence Architecture

MongoDB

{ _id: 78234974,maker : ”Agusta",type : sportbike,rake : 7,trail : 3.93,engine : {

type : "internal combustion",layout : "inline"cylinders : 4,displacement : 750,

},transmission : {

type : "cassette",speeds : 6,pattern : "sequential”,ratios : [ 2.7, 1.94, 1.34, 1, 0.83, 0.64 ]

}}

Primary Key,Auto indexed

Page 25: Webinar: MongoDB and Polyglot Persistence Architecture

MongoDB

{ _id: 78234974,maker : ”Agusta",type : sportbike,rake : 7,trail : 3.93,engine : {

type : "internal combustion",layout : "inline"cylinders : 4,displacement : 750,

},transmission : {

type : "cassette",speeds : 6,pattern : "sequential”,ratios : [ 2.7, 1.94, 1.34, 1, 0.83, 0.64 ]

}}

Secondaryindexes

Page 26: Webinar: MongoDB and Polyglot Persistence Architecture

MongoDB

{ _id: 78234974,maker : ”Agusta",type : sportbike,rake : 7,trail : 3.93,engine : {

type : "internal combustion",layout : "inline"cylinders : 4,displacement : 750,

},transmission : {

type : "cassette",speeds : 6,pattern : "sequential”,ratios : [ 2.7, 1.94, 1.34, 1, 0.83, 0.64 ]

}}

Projectionsdb.vehicles.find ( {_id:78234974 }, { engine:1,_id:0 })

Page 27: Webinar: MongoDB and Polyglot Persistence Architecture

Data Model

RDBMS MongoDBTable, View ➜ CollectionRow ➜ DocumentIndex ➜ IndexJoin ➜ Embedded DocumentForeign Key ➜ ReferencePartition ➜ Shard

Page 28: Webinar: MongoDB and Polyglot Persistence Architecture

Flexible Schemas

{ maker : "M.V. Agusta",type : sportsbike,engine : {

type : ”internal combustion",

cylinders: 4,displacement : 750

},rake : 7,trail : 3.93

}{ maker : "M.V. Agusta",

type : Helicopterengine : {

type : "turboshaft"layout : "axial”,massflow : 1318

},Blades : 4undercarriage : "fixed"

}

Page 29: Webinar: MongoDB and Polyglot Persistence Architecture

Flexible Schemas

Discriminator column

{ maker : "M.V. Agusta",type : sportsbike,engine : {

type : ”internal combustion",

cylinders: 4,displacement :

750},rake : 7,trail : 3.93

}{ maker : "M.V. Agusta",

type : Helicopterengine : {

type : "turboshaft"

layout : "axial”,massflow : 1318

},Blades : 4undercarriage : "fixed"

}

Page 30: Webinar: MongoDB and Polyglot Persistence Architecture

Flexible Schemas

Shared indexing strategy

{ maker : "M.V. Agusta",type : sportsbike,engine : {

type : ”internal combustion",

cylinders: 4,displacement :

750},rake : 7,trail : 3.93

}{ maker : "M.V. Agusta",

type : Helicopterengine : {

type : "turboshaft"

layout : "axial”,massflow : 1318

},Blades : 4undercarriage : "fixed"

}

Page 31: Webinar: MongoDB and Polyglot Persistence Architecture

Flexible Schemas

Polymorphic Attributes

{ maker : "M.V. Agusta",type : sportsbike,engine : {

type : ”internal combustion",

cylinders: 4,displacement :

750},rake : 7,trail : 3.93

}{ maker : "M.V. Agusta",

type : Helicopter,engine : {

type : "turboshaft”,

layout : "axial”,massflow : 1318

},Blades : 4,undercarriage : "fixed"

}

Page 32: Webinar: MongoDB and Polyglot Persistence Architecture

Tao of MongoDB

• Model data for use, not storage• Avoid ad-hoc queries• Index effectively, index efficiently

Page 33: Webinar: MongoDB and Polyglot Persistence Architecture

Strong Consistency vs.

Eventual Consistency

Page 34: Webinar: MongoDB and Polyglot Persistence Architecture

Availability

Page 35: Webinar: MongoDB and Polyglot Persistence Architecture

Availablity

Page 36: Webinar: MongoDB and Polyglot Persistence Architecture

Fail-over

Page 37: Webinar: MongoDB and Polyglot Persistence Architecture

Fail-over

Page 38: Webinar: MongoDB and Polyglot Persistence Architecture

Strong vs. Eventual Consistency

Page 39: Webinar: MongoDB and Polyglot Persistence Architecture

Strong vs. Eventual Consistency

Node A

Node B

Node C

Node E

Node D

Client 1

Client 2

Page 40: Webinar: MongoDB and Polyglot Persistence Architecture

Strong vs. Eventual Consistency

Node A

Node B

Node C

Node E

Node D

Client 1

Client 2

Write

Page 41: Webinar: MongoDB and Polyglot Persistence Architecture

Strong vs. Eventual Consistency

Node A

Node B

Node C

Node E

Node D

Client 1

Client 2

Read

Write

Page 42: Webinar: MongoDB and Polyglot Persistence Architecture

Strong vs. Eventual Consistency

Node A

Node B

Node C

Node E

Node D

Client 1

Client 2

Write

Read

Page 43: Webinar: MongoDB and Polyglot Persistence Architecture

Strong vs. Eventual Consistency

Node A

Node B

Node C

Node E

Node D

Client 1

Client 2

Write

Read

Page 44: Webinar: MongoDB and Polyglot Persistence Architecture

Analytics

Page 45: Webinar: MongoDB and Polyglot Persistence Architecture

45

Hadoop

A framework for distributed processing of large data sets• Terabyte and petabyte datasets• Data warehousing• Advanced analytics• Not a database• No indexes• Batch processing

Page 46: Webinar: MongoDB and Polyglot Persistence Architecture

46

Use Cases

• Behavioral analytics• Segmentation• Fraud detection• Prediction• Pricing analytics• Sales analytics

Page 47: Webinar: MongoDB and Polyglot Persistence Architecture

47

Data Management

HadoopOffline ProcessingAnalyticsData Warehousing

MongoDBOnline OperationsApplicationOperational

Page 48: Webinar: MongoDB and Polyglot Persistence Architecture

48

Typical Implementations

Application Server

Page 49: Webinar: MongoDB and Polyglot Persistence Architecture

49

MongoDB as an Operational Store

Application Server

Page 50: Webinar: MongoDB and Polyglot Persistence Architecture

50

Data Flows

HadoopConnector

BSON Files

MapReduce & HDFS

Page 51: Webinar: MongoDB and Polyglot Persistence Architecture

51

Cluster

MONGOS

SHARD A

SHARDB

SHARD C

SHARD D

MONGOS Client

Page 52: Webinar: MongoDB and Polyglot Persistence Architecture

52

Page 53: Webinar: MongoDB and Polyglot Persistence Architecture

53

Hadoop / Spark Trade-offs

Plus• Access to Analytics

Libraries• Processes unstructured

data• Handles petabyte data

sets

Minus• Overhead of a separate

distributed system• Writing MapReduce not

for the faint of heart• Designed for batch

oriented processing

Page 54: Webinar: MongoDB and Polyglot Persistence Architecture

54

Relational for Reporting & Business Intelligence

Plus• Existing ecosystem of BI

tools• Lower overhead than

Hadoop clusters• Large pool of expertise

and talent

Page 55: Webinar: MongoDB and Polyglot Persistence Architecture

RDBMSPrimary ETL

Oplog

Replication

Page 56: Webinar: MongoDB and Polyglot Persistence Architecture

Integrations & ETL

RDBMSPrimary

Page 57: Webinar: MongoDB and Polyglot Persistence Architecture

LucenePrimaryMongo

Connector

Oplog

Replication

Integrations with Search Solutions

Page 58: Webinar: MongoDB and Polyglot Persistence Architecture

Considerations

• Increased system complexity

• Operations overhead• Increased expertise

Page 59: Webinar: MongoDB and Polyglot Persistence Architecture

Thanks!

{ Name: ‘Bryan Reinero’,

Title: ‘Developer Advocate’,

Twitter: ‘@blimpyacht’,

Email: ‘[email protected]’ }