34
POLYGLOT PERSISTENCE alex brandt sr developer Wednesday, August 21, 13

Polyglot Persistence

Embed Size (px)

Citation preview

Page 1: Polyglot Persistence

POLYGLOT PERSISTENCE

alex brandtsr developer

Wednesday, August 21, 13

Page 2: Polyglot Persistence

2

Wednesday, August 21, 13

Page 3: Polyglot Persistence

3

Wednesday, August 21, 13

Page 4: Polyglot Persistence

4

Wednesday, August 21, 13

Page 5: Polyglot Persistence

5

RDBMS may not be the best fit

Wednesday, August 21, 13

Page 6: Polyglot Persistence

6

Wednesday, August 21, 13

Page 7: Polyglot Persistence

7

Wednesday, August 21, 13

Page 8: Polyglot Persistence

INTRODUCTION TO NOSQL

• NoSQL Database (1998)• NoREL• “Not only SQL”• NoSQL (2009)

8

Wednesday, August 21, 13

Page 9: Polyglot Persistence

9

5 Characteristics

Wednesday, August 21, 13

Page 10: Polyglot Persistence

10

Non-relational

Wednesday, August 21, 13

Page 11: Polyglot Persistence

11

Distributed

Wednesday, August 21, 13

Page 12: Polyglot Persistence

12

Open-source

Wednesday, August 21, 13

Page 13: Polyglot Persistence

13

Horizontally Scalable

Wednesday, August 21, 13

Page 14: Polyglot Persistence

14

Schema-less

Wednesday, August 21, 13

Page 15: Polyglot Persistence

orders

customers

order lines

credit cards

ID: 1001

line items:

customer: Ann

0321293533

0321601912

0131495054

2

1

1

$48 $48

$39

$51

$39

$51

payment details:

Card: AmexCC #: 12345expires: 04/2001

15

Wednesday, August 21, 13

Page 16: Polyglot Persistence

16

Types in Detail

Wednesday, August 21, 13

Page 17: Polyglot Persistence

Key/Value DatabaseS

17

Wednesday, August 21, 13

Page 18: Polyglot Persistence

Key/Value DatabaseS

• Good Use Cases:

• Storing Session Information

• User Profiles & Preferences

• Shopping Cart Data

• Bad Use Cases:

• Data Relationships

•Multi-operation Transactions

•Query by Data

18

Wednesday, August 21, 13

Page 19: Polyglot Persistence

Key/Value DatabaseS

• Good Use Cases:

• Storing Session Information

• User Profiles & Preferences

• Shopping Cart Data

• Bad Use Cases:

• Data Relationships

•Multi-operation Transactions

•Query by Data

19

Wednesday, August 21, 13

Page 20: Polyglot Persistence

document Database

20

Wednesday, August 21, 13

Page 21: Polyglot Persistence

document Databases

•Good Use Cases:

• Event Logging

• Blogging Platforms

• Real-time Analytics

• Article storage

• Bad Use Cases:

• Complex Transactions

•Queries against Varying Aggregate Structures

21

Wednesday, August 21, 13

Page 22: Polyglot Persistence

document Databases

•Good Use Cases:

• Event Logging

• Blogging Platforms

• Real-time Analytics

• Article storage

• Bad Use Cases:

• Complex Transactions

•Queries against Varying Aggregate Structures

22

Wednesday, August 21, 13

Page 23: Polyglot Persistence

COLUMN FAMILY

23

Wednesday, August 21, 13

Page 24: Polyglot Persistence

24

Wednesday, August 21, 13

Page 25: Polyglot Persistence

COLUMN-FAMILY datastores

•Good Use Cases:

• Event Logging

• Blogging Platforms

• Counters (page visits)

• Expiring Usage

• Bad Use Cases:

• ACID transactions required

• Early prototype applications

25

Wednesday, August 21, 13

Page 26: Polyglot Persistence

graph database

26

Wednesday, August 21, 13

Page 27: Polyglot Persistence

Amanda

KNOWS

KNOWS

KNOWS

Robert

Gerry

Lamar

KNOWS

App 1

BUILTBUILT

KNOWS

App 2

USES

BUILT

Christie

KNOWS

Destiny

Jessica

KNOWS

App 3

BUILT

USES

USES

USES

KNOWS

graph database

27

Wednesday, August 21, 13

Page 28: Polyglot Persistence

graph databases

•Good Use Cases:

• Connected Data

• Location-based services

• Recommendation engines

• Bad Use Cases:

• Ability to update specific aggregates

28

Wednesday, August 21, 13

Page 29: Polyglot Persistence

Companies using nosql

29

DATABASE COMPANIES

Wednesday, August 21, 13

Page 30: Polyglot Persistence

THE FUTURE IS POLYGLOT

30

Neo4Jdatabase

Cassandradatabase

Couchdatabase

MongoDBdatabase

RELATIONALDATABASE

Graph-structureddomain rules

Columnar dataaccess with

decentralization

Documentstructures

Document structureswith offlineprocessing

(Actors) (Actors)

(Actors)(Actors)

Asynchronous message passing

MODULE 1

MODULE 2

MODULE 3

MODULE 4

IEEE Software Sept/October 2010 - Debasish Ghosh / Twitter @debasishg

Wednesday, August 21, 13

Page 31: Polyglot Persistence

31

POLYGLOT PATTERN: cache

ORDERTAKING

RESTAURANTMANAGEMENT

REDISCACHE

MYSQL DATABASE SECONDFIRST

CONSUMERRESTAURANT

OWNER

Credit: @crichardson

Wednesday, August 21, 13

Page 32: Polyglot Persistence

32

POLYGLOT PATTERN: write to sql and NOSQL

NEWTWEET

INSERT

LPUSHXLTRIM

MySQL

TWEETS

FOLLOWS

FOLLOWERS

Redis: Timeline

FOLLOWER 1

FOLLOWER 2

FOLLOWER 3

Avoidexpensive

MySQL joins

Credit: @crichardson

Wednesday, August 21, 13

Page 33: Polyglot Persistence

33

POLYGLOT PATTERN: REPLICATE FROM MYsql to NOSQL

QUERYSERVICE

UPDATESERVICE

REDISMYSQL

DATABASE

SYSTEMOF RECORD

MATERIALIZED VIEW

READER WRITER

replicate and

denormalize

query() update()

Credit: @crichardson

Wednesday, August 21, 13

Page 34: Polyglot Persistence

34

Atomic

Consistent

Isolated

Durable

ACID to base

Basically Available

Soft state

Eventually consistent

Wednesday, August 21, 13