glue con denver may 2015 sql to nosql

24
Peter Milne [email protected] @helipilot50 helipilot50 SQL to NoSQL Migration

Upload: peter-milne

Post on 06-Aug-2015

344 views

Category:

Technology


2 download

TRANSCRIPT

Peter [email protected]

@helipilot50

helipilot50

SQL to NoSQL Migration

Wisdom vs Guessing

"Everything that can be invented has been invented.” - Charles Holland Duell – US Patent Office 1899

“Insanity is doing the same thing over & over again expecting different results” – Albert Einstein

Why we love RDBMS

■Reliability■Concurrency made easy

■Atomic■Consistency■Isolation■Durability

■2 phase commit■Rigorous Schema■Normalization (normal forms)

…And it is what we all know

Edgar “Ted” Codd

Why switch to NoSQL

■Scalability■Performance■Developer productivity

RDBMS and NoSQL differences

■RDBMS is accessible for many types of applications

■Schema helps to control rules common for everybody

■NoSQL is about focusing on particular need

■Model your data for specific use case

■Speed at Scale

10 Reasons why NoSQL is the Key to Velocity

1. RAM is fast2. Easy for developers3. Flex schema4. Read / write agility5. Scale-out clustering works6. Flash-enabled for big data7. Geographic replication8. Cloud or On-premise9. KVS+ for fast analytics10. Open source

Polyglot Persistence

■Different solutions are designed to solve different problems ■session & fast transactions ■Cache■Aggregations■Analytical ad-hock scans■Traversal

■The requirements for OLTP and OLAP storages are very different

NoSQL stereotypes

8

NoSQL types: Key-value & Key-document

Key-Value: ■Riak■Redis■Aerospike■Kyoto Tycoon

Key-Document■MongoDB■CouchBase

NoSQL types: Column oriented & Graph

Column oriented■Cassandra■Hbase

Graph Databases■Neo4j■OrientDB

NoSQL Data Modeling Basics

Normalization

■Normalization is the process of structuring relational database schema such that most ambiguity is removed. The stages of normalization are referred to as normal forms and progress from the least restrictive (First Normal Form) through the most restrictive (Fifth Normal Form).

De-normalization or Duplication

■De-normalization is OK■Immutable data

■Aggregation vs Association■“Consists of” vs “related to”

Consists of Related to

Aggregates

Aggregation is a technique of embedding data structures into each other.

Why?■Simple read/write is fast■Optimize storage I/O■Parallelism through clusteringWhat it costs■Updates and Queries are

heavy and complex

Aggregation gives you Velocity

Joins in your code

Not all the questions can be answered by the same data model.■Frequent questions move to the data model

■Composite key, aggregation, etc

■Infrequent questions done as an application Join

Example: User profile and Photo

Join

Composite keys

Single record, 2 pieces of related data, Single composite key

■Chat example:

■Bank account example:

Append

As events occur Append them to a List*

■Banking example■Deposit■Withdrawal■Deposit

*Row oriented■List, Byte Array, Set

*Column oriented■Add a column

Append

Uncle Pete’s advice

Practical migration steps

■What do you want to achieve■Speed at Scale

■Know your traffic■Know your data■What are you willing to sacrifice

■Consistency, Transactions, Data loss

■Apply polyglot persistence■Model you data

Latency of your application

Latency = Sum(LD) + Sum(LS)

■LD = Device latency

■LS = Stupidity latency

■Minimize stupidity

Right tool for the job

Load test

■Simulation■Simulate real load

■Nothing is better than real data■Record live data and playback in testing

Finally..

A well designed and build application should

■Deliver the correct result

■Perform adequately

■Be maintainable by the average Guy or Girl

Klausimai

Questions

Dúvidas

Fragen質問がありますか

Perguntas