nosql search roadshow zurich 2013 - polyglot persistence with no sql

61
© Zühlke 2013 Michael Lehmann & Roman Kuczynski Polyglot Persistence with NoSQL Advanced software architecture by using multiple persistence technologies 19. September 2013

Upload: michael-lehmann

Post on 12-May-2015

623 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

© Zühlke 2013

Michael Lehmann & Roman Kuczynski

Polyglot Persistence with NoSQLAdvanced software architecture by using multiple persistence technologies

19. September 2013

Page 2: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Abstract

Alternative data persistence technologies like NoSQL emerged since more than 10 years, but we developers hesitate to open our horizon for these new approaches. Why should we?Relational databases dominated the IT industry for a long time and served us very well. Everybody knows SQL and is used to the relational data model with all its advantages and disadvantages.

But the one who are looking beyond their borders will find a richness of NoSQL technologies and products.Every product has its own properties and characteristics. How can we differentiate them? Is it all about smart decisions, or do we have more possibilities? We will go into the world of NoSQL and explain the different kind of NoSQL products, when to use them and what is about polyglot persistence to be.

Page 3: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

SELECT *FROM dbo.PresentationWHERE Title LIKE 'Polyglot pers%'

Page 4: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

http://mechiz.deviantart.com/art/India-32-327938771

Our holy cow!

Page 5: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

http://www.deviantart.com/art/swiss-army-knife-185060119

One size fits all

Page 6: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Michael Lehmann @lehmamic

Senior Software Engineer @Zühlke since

2012

.Net enterprise and cloud applications

Roman Kuczynski @qtschi

Senior Software Engineer @Zühlke since

2011

Data(base) architectures, BI and Big Data

Page 7: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Borat @BoratNoSQL

Why should I change? It worked for me until now!

Page 8: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

http://memod.deviantart.com/art/Racing-Lights-12889655

Listen to the business

Page 9: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

RDBMS

Volume

Page 10: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

RDBMS

Volume

Velocity

Page 11: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

RDBMS

Volume

Velocity

Variability

Page 12: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

RDBMS

Volume

AgilityVelocity

Variability

Page 13: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Borat @BoratNoSQL

Sounds plausible, but what options do we have?

Page 14: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

#NoSQL

Page 15: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Increasing performance through scale out

Page 16: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Roger Federer

Rafael Nadal

Andy Murray

N. Djokovic

Scaling by sharding

Page 17: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Roger Federer

Roger Federer

Scaling by replication

Roger Federer

N. Djokovic N. Djokovic N. Djokovic

Page 18: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Impedance mismatch using relational databases

public class BlogPost{ public int Id { get; set; } public string Content { get; set; } public List<string> Tags { get; set; }}

Page 19: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Design for the relational model

public class BlogPost{ public int Id { get; set;} public List<Tag> Tags { get; set; }}

public class Tag{ public int Id { get; set; } public PlogPost BelongsTo { get; set; } public string Name { get; set; }}

BlogPost- Id (int)- Content (varchar)

Tag- Id (int)- BlogPostId (int)- Name (varchar)

Page 20: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

NoSQL databases increase productivity

var post = new BlogPost{ Id = 1, Content = "Any text content", Tags = new [] { "NoSQL", "Cloud", "PolyglotPersistence" }};

collection.Insert(post);

Page 21: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Data integrity cannot be enforced

Page 22: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

NoSQL databases are eventual consistent

Page 23: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

NY ZH

Free Free

We look for a hotel room

Page 24: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

NY ZH

booked Free

We book the room

Page 25: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

NY ZH

booked FreeInconsistency

Inconsistency window

Page 26: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

NY ZH

booked FreeInconsistency

Someone else books the same room

Page 27: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

NY ZH

booked bookedInconsistency

Conflict!

Page 28: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Why not handle such cases by business?

Page 29: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

performance consistency

Page 30: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

What do we have in our toolbox?

Page 31: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

A lot of database products

Page 32: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Borat @BoratNoSQL

I feel swamped, how can I differentiate these products?

Page 33: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Key-value stores

Page 34: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Document stores

Page 35: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

{ "playerId": 1, "firstName": "Roger", "lastName": "Federer", "ranking": "#1", "address": { "city": "Wollerau" } "sponsors“: [ { "id": 1, "name": "Nike" "amount": "16’000 SFR" }, { "id": 2, "name": "Lindt" "amount": "5’000 SFR" }, { "id": 3, "name": "Credit Suisse" "amount": “13’000 SFR" }]}

The document store data model

Page 36: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Column-family stores

Page 37: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Row 1 FirstName:Roger LastName:Federer

Row 2 FirstName:Andy LastName:Murray

Row 3 NickName:Rafa LastName:Nadal

Row n-1 Fruit:Apple Price:1.40$

Row n Fruit:Cherry Price:2.60$

Column-Family: Players Column-Family: Fruits

The column-family data model

Page 38: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Graph databases

Page 39: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

The graph data model

Node [1]Name = ‘John’

Node [2]Name = ‘Sara’

Node [5]Name = ‘Joe’

Node [3]Name = ‘Maria’

Node [4]Name = ‘Steve’

friend friend

friend friend

Page 40: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql
Page 41: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

http://vallo29.deviantart.com/art/The-choice-150871274

Decisions, decisions…

Page 42: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Borat @BoratNoSQL

With every database I have to take tradeoffs into account, I don’t want to choose only one!

Page 43: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Pol·y·glot – AdjectiveKnowing or using several languages

Per·sist·ence – NounThe continued or prolonged existence of

something

Page 44: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Retail Store

Recomendations

Neo4J

Product Catalog

Raven DB

Financial Data

MSSQL

Shopping Cart

Redis

Polyglot persistence illustrated

Page 45: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Borat @BoratNoSQL

Sounds great! But where is the catch?

Page 46: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

We need appropriate skills

Page 47: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

http://www.deviantart.com/art/architecture-71406568

Invest in software architecture

Page 48: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Integration databases have been used for years

Database

ApplicationA

ApplicationB

Page 49: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Polyglot persistence doesn’t work here

Database1

ApplicationA

ApplicationB

Database2

Page 50: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Application databases do not share it’s data

Database1

ApplicationA

ApplicationB

Database2

Page 51: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Borat @BoratNoSQL

Fine! But I have not only one application.

Page 52: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Application database with SOA

Database1

ApplicationA

ApplicationB

Database2

Service

Page 53: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

It’s all about layers

Page 54: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Well known layers

Presentation Layer

Domain Layer

Resource Access Layer ( Data Access Layer)

Resources

Page 55: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Common data tier design

Presentation

Domain

DAL

Resources RDBMS

Search

Transactions

Caching

Blobs

Triggers

Reporting

User Interface

Relational-ObjectObject-Relational

Page 56: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

http://gundross.deviantart.com/art/Chair-72928743

The truth of reusability

Page 57: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Data access with reusable and seamless services

Presentation

Domain

DAL

Resources RDBMS

Search

Transactions

Caching

Blobs

Triggers

Reporting

User Interface

Relational-ObjectObject-Relational

Presentation

Domain

DAL

Resources

User Interface

Search

Transactions

Caching

Blobs

Batch

Reporting

Key-Value Document RDBMS

Page 58: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Putting all together

Key-Value Document RDBMS

Search

Caching

Reporting

Domain Services

User Interface

Database Tier

Middle Tier

Page 59: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Use the right tool!

Page 60: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

Resources

NoSQL DistilledAuthor: Martin Fowler, Pramod J. SadalageISBN: 978-0321826626

Making Sense of NoSQLAuthor: Dan McCreary, Ann KellyISBN: 978-1617291074

Linkshttp://nosql-database.org/http://en.wikipedia.org/wiki/NoSQL

Page 61: NoSQL Search Roadshow Zurich 2013 - Polyglot persistence with no sql

• Click to edit picture stylesImage Source

Thank you!