際際滷

際際滷Share a Scribd company logo
Polyglot
Persistence
Majid Fatemian
R E D V E N T U R E S
@majidfn
Relational Non-Relational Key-Value Big Data
Application
Relational
Application
Relational Relational Non-Relational
Relational
DATA
BIG
DATA
Capture
Search
Storage
Q u e r y
Privacy
Visualize
Analysis
Non-Relational
1 2 3
Non-Relational Cluster Schemaless
I. Document
II. Key-Value
III. Graph
IV. Column
MongoDB, CouchBase
Memcache, Redis
Neo4J, OrientDB
Cassandra, HBase
P
C A
AvailabilityConsistency
Partition Tolerance
P
A
AvailabilityConsistency
Partition Tolerance
C
CP
CA AP
MySQL
Postgres
MongoDBCouchBase
Cassandra
Riak
Charlotte Software Engineering Meetup - Jan.2015
2 x
1 x
1 x
Charlotte Software Engineering Meetup - Jan.2015
2011
2012
2013
2014
2011
2012
2013
201
Charlotte Software Engineering Meetup - Jan.2015
Application
Normalized
ACID
{Consistency
Relational
Replication
Fault Tolerance
Availability
{Relational
OPs / DBAs
Tools
Devs{DevOps
Relational
2011
2012
2013
201
Scalability
Relational
Schema
Relational
{
player_id: 1234,
* level: 40,
* duration: 75,
* activity: activity,
game_id: 4001,
platform: WiiU,
di鍖culty_level: medium,
repetition: 178,
score: 450,
endurance:3
}
{
player_id: 1234,
level: 12,
duration: 120,
activity: activity
}
Aggregated
Detailed
stats
stats
Players Pro鍖les
Individual Activities
Distribution
Relational
Data C
Data B
Data A
Data Access Layer
ACID
Transaction
Partitioning
Replication
Tools
OPs
Data Volume
Fixed Schema
Scale Up
Manual Sharding
+ -
NoSQL
...
mongoDB
1 2 3
OPs Devs Community
Schema-less
Non-Relational
player_id: 1234,
* level: 40,
* duration: 75,
* activity: activity,
game_id: 4001,
platform: WiiU,
di鍖culty_level: 2,
repetition: 178,
score: 450,
endurance:3
player_id: 1234,
level: 75,
duration: 120,
activity: activity
Scalability
Non-Relational
Scalability
Non-Relational
+
Sharding
Non-Relational
Sharding
Non-Relational
Data A
{key}
Sharding
Non-Relational
Data A
A
Data B
B
Data C
C
{key}
Map/Reduce
Non-Relational
K, V
K,V1 K,V2 K,V3
Map/Reduce
Non-Relational
Query
K, V
K,V1 K,V2 K,V3
Map/Reduce
Non-Relational
Query
Map
K, V
K,V1 K,V2 K,V3
Map/Reduce
Non-Relational
Map
K,V1 K,V2 K,V3
Map/Reduce
Non-Relational
Result
ReduceMap
K,V1 K,V2 K,V3
Denormalized
Non-Relationalread /
}write
Disk Space
Data Model
Non-RelationalQuery
Aggregation
}
Eventual-
Consistency
Non-Relational
X1
X1 X1
Eventual-
Consistency
Non-Relational
X2
W
X1 X1
X2
Eventual-
Consistency
Non-Relational
X2
W
X1 X1
R
X1
X2
Eventual-
Consistency
Non-Relational
X2
W
X2
X2
R
X2
X2
Balancer
Non-Relational
Balancer
Non-Relational
+
Balancer
Non-Relational
Non-Relational
Resilience
A B C
Non-Relational
Resilience
A C
Locking
Non-RelationalDB Level (2.2)
}Document Level (3.x)
Backup
Non-Relational
Point-in-time
Denormalized data
Disk Space
Expertise
Complex Querying
Eventual Consistency
Resource Usage
DB-Level Locking
-
Schema-Less
Aggregated Data
Large Scale Data
Sharding
Map/Reduce
Memory Storage
Journaling
+
Random Pro鍖le
Search
(1M)
Full History
Retrieval
(6M)
Insert
(6M)
Aggregation
Map/Reduce
(6M)
0
0.003
0.005
0.008
0.01
MySQL
MongoDB
Persistence
Polyglot
Players Pro鍖le
Leaderboards
Activity Details
Charlotte Software Engineering Meetup - Jan.2015
Total Sum
Activity 1
Activity n
Activity m
Shard1
Shard2
Con鍖g
Data Access Layer
Application
The
Challenge
Inconsistency1
Data Access Layer
Commit
2-Phase
Data Access Layer
W
Pending
Commit
2-Phase
Data Access Layer
Pending
W
Commit
2-Phase
Data Access Layer
Done
Commit
2-Phase
2 Latency
2 Latency
vs. Consistency
Operations3
Operations3 Exponential complexity
Availability4
Availability4 Plan for failure
Data Access Layer
Data Access Layer
Data Access Layer
Data Integrity5
Data Integrity5 Backward compatibility
Unit
{TEST Integration
Functional
Data Migration6
Charlotte Software Engineering Meetup - Jan.2015
Pro鍖le
History }
{
profile:
{
GUID:,
platform:
{
name:xbox,
xuid:
}
},
activity:,
duration:,
datetime:
}
3rd Party
1 One-Shot Migration
1 One-Shot Migration
4 hours !!
1 One-Shot Migration
4 hours !!
Live !!
2 Profile versioning
+1
V
+1
1
V
+1
1
V
+1
2
Charlotte Software Engineering Meetup - Jan.2015
Charlotte Software Engineering Meetup - Jan.2015
Final
Results
Scalability
2011 2012 2013 2014
9x response time
3 years uptime
Go Hybrid!>
Go Hybrid!
Thoughtfully
>
Thank
YOU!
@majidfn

More Related Content

Charlotte Software Engineering Meetup - Jan.2015