polyglot persistence - confoo 2016

87
Polyglot Persistence

Upload: majid-fatemian

Post on 11-Apr-2017

9.853 views

Category:

Internet


5 download

TRANSCRIPT

Page 1: Polyglot Persistence - Confoo 2016

PolyglotPersistence

Page 2: Polyglot Persistence - Confoo 2016

Majid Fatemian

R E D V E N T U R E S

@majidfn

Page 3: Polyglot Persistence - Confoo 2016

Relational Non-Relational Key-Value Big Data

Page 4: Polyglot Persistence - Confoo 2016

Application

Relational

Page 5: Polyglot Persistence - Confoo 2016

Application

Relational Relational Non-Relational

Page 6: Polyglot Persistence - Confoo 2016

Relational

Page 7: Polyglot Persistence - Confoo 2016

BIGDATA

Page 8: Polyglot Persistence - Confoo 2016

Capture

Search Storage

Q u e r y

Privacy Visualize

Analysis

Page 9: Polyglot Persistence - Confoo 2016

Non-Relational

Page 10: Polyglot Persistence - Confoo 2016

1 2 3Non-Relational Cluster Schemaless

Page 11: Polyglot Persistence - Confoo 2016

2 x

1 x

1 x

Page 12: Polyglot Persistence - Confoo 2016
Page 13: Polyglot Persistence - Confoo 2016

2011

2012

2013

2014

Page 14: Polyglot Persistence - Confoo 2016

2011

2012

2013

2014

Page 15: Polyglot Persistence - Confoo 2016
Page 16: Polyglot Persistence - Confoo 2016

Application

Page 17: Polyglot Persistence - Confoo 2016

ACID

Normalized{ConsistencyRelational

Page 18: Polyglot Persistence - Confoo 2016

Player ID Map ID Difficulty Score1000 223 E 52000 673 H 4.51000 451 M 42000 980 H 3

Activity

Player ID Name Location1000 John US2000 Catherine CA3000 Paul CA4000 Kylee US

Profile

Page 19: Polyglot Persistence - Confoo 2016

Replication

Fault ToleranceAvailability{Relational

Page 20: Polyglot Persistence - Confoo 2016

OPs / DBAs Tools Devs{DevOps

Relational

Page 21: Polyglot Persistence - Confoo 2016

2011

2012

2013

2014

Page 22: Polyglot Persistence - Confoo 2016
Page 23: Polyglot Persistence - Confoo 2016
Page 24: Polyglot Persistence - Confoo 2016

ScalabilityRelational

Page 25: Polyglot Persistence - Confoo 2016

DistributionRelational

Data CData B

Data A

Data Access Layer

Page 26: Polyglot Persistence - Confoo 2016

SchemaRelational

{ player_id: 1234, * level: 40, * duration: 75, * activity: activity, game_id: 4001, platform: WiiU, difficulty_level: medium, repetition: 178, score: 450, endurance:3}

{ player_id: 1234, level: 12, duration: 120, activity: activity}

Page 27: Polyglot Persistence - Confoo 2016

Total

Detailed

stats

stats

Players’ Profiles

Individual Activities

Aggregatedstats

Categorized

Page 28: Polyglot Persistence - Confoo 2016

ACID Transaction Partitioning Replication

Tools OPs

Data Volume Fixed Schema Scale Up Manual Sharding

+ -

Page 29: Polyglot Persistence - Confoo 2016

NoSQL...

Page 30: Polyglot Persistence - Confoo 2016

mongoDB

1 2 3OPs Devs Community

Page 31: Polyglot Persistence - Confoo 2016

Schema-lessNon-Relational

player_id: 1234, * level: 40, * duration: 75, * activity: activity, game_id: 4001, platform: WiiU, difficulty_level: 2, repetition: 178, score: 450, endurance:3

player_id: 1234, level: 75, duration: 120, activity: activity

Page 32: Polyglot Persistence - Confoo 2016

ScalabilityNon-Relational

Page 33: Polyglot Persistence - Confoo 2016

ScalabilityNon-Relational

+

Page 34: Polyglot Persistence - Confoo 2016

ShardingNon-Relational

Data A

{key}

Page 35: Polyglot Persistence - Confoo 2016

ShardingNon-Relational

Data A

A

Data B

B

Data C

C

{key}

Page 36: Polyglot Persistence - Confoo 2016

Map/ReduceNon-Relational

QueryK, V

K,V1 K,V2 K,V3

Page 37: Polyglot Persistence - Confoo 2016

Map/ReduceNon-Relational M

ap

K,V1 K,V2 K,V3

Page 38: Polyglot Persistence - Confoo 2016

Map/ReduceNon-Relational

ResultReduce

Map

K,V1 K,V2 K,V3

Page 39: Polyglot Persistence - Confoo 2016

DenormalizedNon-Relationalread / }write

Disk Space

Page 40: Polyglot Persistence - Confoo 2016

Player ID Map ID Difficulty Score1000 223 E 52000 673 H 4.51000 451 M 42000 980 H 3

Activity

Player ID Name Location1000 John US2000 Catherine CA3000 Paul CA4000 Kylee US

Profile

Page 41: Polyglot Persistence - Confoo 2016

{Name: John, game:1, activity: Mission01, Score: 1245}

{Name: John, game:3, activity: Mission04, score: 5431}

{Name: John, game:1, activity: Mission01, Score: 1245}

Page 42: Polyglot Persistence - Confoo 2016

Data ModelNon-RelationalQuery

Aggregation}

Page 43: Polyglot Persistence - Confoo 2016

Eventual- Consistency

Non-Relational

X2

W

X1 X1

X2

Page 44: Polyglot Persistence - Confoo 2016

Eventual- Consistency

Non-Relational

X2

W

X1 X1

R

X1

X2

Page 45: Polyglot Persistence - Confoo 2016

Eventual- Consistency

Non-Relational

X2

W

X2

X2

R

X2

X2

Page 46: Polyglot Persistence - Confoo 2016

BalancerNon-Relational

Page 47: Polyglot Persistence - Confoo 2016

BalancerNon-Relational+

Page 48: Polyglot Persistence - Confoo 2016

BalancerNon-Relational

Page 49: Polyglot Persistence - Confoo 2016

Non-RelationalResilience

A B C

Page 50: Polyglot Persistence - Confoo 2016

Non-RelationalResilience

A C

Page 51: Polyglot Persistence - Confoo 2016

LockingNon-RelationalDB Level (2.2)}Document Level (3.x)

Page 52: Polyglot Persistence - Confoo 2016

BackupNon-RelationalPoint-in-time

Page 53: Polyglot Persistence - Confoo 2016

Denormalized data Disk Space Expertise Complex QueryingEventual Consistency Resource Usage DB-Level Locking

-

Schema-Less Aggregated Data Large Scale Data

Sharding Map/Reduce

Memory Storage Journaling

+

Page 54: Polyglot Persistence - Confoo 2016

Random ProfileSearch(1M)

Full History Retrieval(6M)

Insert(6M)

AggregationMap/Reduce

(6M)

0

0.003

0.005

0.008

0.01

MySQLMongoDB

Page 55: Polyglot Persistence - Confoo 2016

PersistencePolyglot

Page 56: Polyglot Persistence - Confoo 2016

Players’ Profile Leaderboards

Activity Details

Relational Data

Schema-less Sharding

Page 57: Polyglot Persistence - Confoo 2016

Total Sum

Activity 1

Activity n

Activity m

……

Page 58: Polyglot Persistence - Confoo 2016

Shard 1

Shard 2

Config

Page 59: Polyglot Persistence - Confoo 2016

Data Access Layer

Application

Page 60: Polyglot Persistence - Confoo 2016

TheChallenge

Page 61: Polyglot Persistence - Confoo 2016

Inconsistency1

Page 62: Polyglot Persistence - Confoo 2016

Data Access Layer

W

Pending

Commit2-Phase

Page 63: Polyglot Persistence - Confoo 2016

Data Access Layer

Pending

W Commit2-Phase

Page 64: Polyglot Persistence - Confoo 2016

Data Access Layer

Done

Commit2-Phase

Page 65: Polyglot Persistence - Confoo 2016

2 Latencyvs. Consistency

Page 66: Polyglot Persistence - Confoo 2016

Operations3 Exponential complexity

Page 67: Polyglot Persistence - Confoo 2016

Availability4 Plan for failure

Page 68: Polyglot Persistence - Confoo 2016

Data Access Layer

Page 69: Polyglot Persistence - Confoo 2016

Data Access Layer

Page 70: Polyglot Persistence - Confoo 2016

Data Access Layer

Page 71: Polyglot Persistence - Confoo 2016

Data Integrity5Backward compatibility

Page 72: Polyglot Persistence - Confoo 2016

Unit{TEST IntegrationFunctional

Page 73: Polyglot Persistence - Confoo 2016

Data Migration6

Page 74: Polyglot Persistence - Confoo 2016
Page 75: Polyglot Persistence - Confoo 2016

Profile

History }{ profile: { GUID:…, platform: { name:’xbox’, xuid:… } }, activity:…, duration:…, datetime:… }

3rd Party

Page 76: Polyglot Persistence - Confoo 2016

1 One-Shot Migration4 hours !!

Live !!2 Profile versioning

Page 77: Polyglot Persistence - Confoo 2016

V+11

Page 78: Polyglot Persistence - Confoo 2016

V+11

Page 79: Polyglot Persistence - Confoo 2016

V

+1

2

Page 80: Polyglot Persistence - Confoo 2016
Page 81: Polyglot Persistence - Confoo 2016

FinalResults

Page 82: Polyglot Persistence - Confoo 2016

Scalability

2011 2012 2013 2014

Page 83: Polyglot Persistence - Confoo 2016

9x response time

Page 84: Polyglot Persistence - Confoo 2016

3 years uptime

Page 85: Polyglot Persistence - Confoo 2016

Go Hybrid!Thoughtfully

>

Page 86: Polyglot Persistence - Confoo 2016

ThankYOU!@majidfn

Page 87: Polyglot Persistence - Confoo 2016

References

Polyglot PersistenceNoSQL Distilled