Top Banner
V1.2 NAA4E @despos | software2cents.wordpress.com Polyglot Persistence for the Common Application Dino Esposito
25

for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

Jul 14, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

V1.2NAA4E

@despos | software2cents.wordpress.com

Polyglot Persistence

for the Common Application

Dino Esposito

Page 2: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 2

Controller

Service

Repositories

Domain services

???

Persistence for the common apps – part 1

Page 3: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 3

Persistence for the common apps – part 2

Controller

ad hoc Repositories ???

Same DB where you stored data

Ad hoc DB to read data from

Ad hoc API (HTTP, memory)

Page 4: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

Architecting .NET Solutions for the EnterpriseNAA4E

@despos | software2cents.wordpress.com

There’s life beyond

relational.

Page 5: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

Architecting .NET Solutions for the EnterpriseNAA4E

@despos | software2cents.wordpress.com

“”— NAA4E, Ch14

More and more, it gets hard to fit real

data into the rigid schema of a relational

model and more often than not a bit of

redundancy helps saving queries thus

making the application faster. No hype

and no religion—it’s just the evolution of

the business and tools.

Page 6: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 6

Relational vs Rest-of-world

Relational databases are not dead (and not

even unhealthy)

NoSQL stores are just another tool that may or

may not be helpful

If you’re an architect who builds software for a client, your

responsibility is understanding the mechanics of the domain and

the characteristics of the data involved and then working out the

best architecture possible.

Page 7: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 7

Getting Familiar with NoSQL

Object store

Graph store

Key-value store

Tabular store

Page 8: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 8

Object stores

Used as plain relational stores

• Saved, indexed, queried

No records, just classes

Each item has its own schema

• Retrieved by ID or through query

Abstracted to a collection of properties

Page 9: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 9

Graph stores

Saves arbitrarily complex collections of data

elements

Support relationships between data elements

Page 10: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 10

Key-value stores

Work like a huge dictionary made of two

fields—key and value

Stored data is retrieved by key

Values are serialized as JSON data

Page 11: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 11

Tabular stores

Differ from relational stores because of lack of

normalization

• Only 1NF fulfilled

John Foo 1234

Jim Bar 4567

Jim Bar 0489

1 John Foo

2 Jim Bar

1

2 4567

2 0489

1234

Page 12: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 12

No-SQL?

(Unpredictably large) volumes of data

• Millions of users

• Thousands of queries per second

Semi-structured data coming in different

forms, and needing same treatment

• Polymorphic data

Event stores

Page 13: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

Most compelling reason to look into

No-SQL stores (document) is

the ability to treat schemaless data

Page 14: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 14

Schemaless

Many different schemas

Unpredictably changing

Polymorphic data—same treatment

Huge number of properties

Page 15: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 15

Schemaless

Schemaless scenarios can be handled in a

relational way

• SQL Server 2014 column-store

• Ad hoc, specific data models

Same tools, nothing to learn

Page 16: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 16

Schemaless

Relational tables can grow fairly big

• Big enough for common applications

Relational tables can be sharded and scaled

out

• Though costs of sharding are on you

Ecosystem of tools and products

• Large expertise within and outside IT departments

Page 17: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 17

Summary of (relational) downsides

Limited support for complex base types in

both reading and writing via SQL (need of

O/RM).

Knowledge of the database structure is

required to create ad hoc queries.

Indexing over a large number of records

(millions of rows) becomes slow.

Page 18: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

Architecting .NET Solutions for the EnterpriseNAA4E

@despos | software2cents.wordpress.com

Eventual

consistencycore difference between

relational and others

Page 19: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 19

Consistency

Eventual consistency is when reads and writes

aren’t aligned to the same data.

Most NoSQL systems are eventually

consistent in the sense that they guarantee

that if no updates are made to a given object

for a sufficient period of time, a query returns

what the last command has written.

Page 20: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 20

Problem of consistency

When the system grows big you can’t expect

full consistency

Expect full consistency in bounded context

In some business scenarios eventual

consistency is not acceptable (i.e., banking)

You can force NoSQL to be consistent

• But taking away the very part of it …

Page 21: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

Architecting .NET Solutions for the EnterpriseNAA4E

@despos | software2cents.wordpress.com

Polyglot persistence is when

you know about all these problems

and feel inspired to try to take

the best of both relational and

No-SQL worlds.

Page 22: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 23

Generic e-commerce system

Data to handle

Customers, orders, payments, products, and all that

relates to a business transaction

What you found out that your users prefer

Documents (PDF of invoices/receipts), SVG maps of

stores/venues

Logs of user’s activity (liked, clicked, viewed)

Correlations: users living in the same area buying

similar products, having “other” in common

Page 23: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

Architecting .NET Solutions for the EnterpriseNAA4E

@despos | software2cents.wordpress.com

• Customers, orders, payments, products• SQL Server or Azure SQL database via EF

• User preferences • Azure table storage

• Documents (PDF of invoices/receipts), SVG maps

of stores/venues• RavenDB or MongoDB

• Logs of user’s activity (liked, clicked, viewed)• Column store such as Cassandra

• Correlations• Graph DB such as Neo4j

Page 24: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise

@despos | software2cents.wordpress.com

Architecting .NET Solutions for the EnterpriseNAA4E 26

Issues

Single vendor

Pet technology

Resistance to change

If you’re not in trouble with it

keep on using SQL

Page 25: for the Common Application - DeveloperMarchdevelopermarch.com/developersummit/2015/report/... · @despos | software2cents.wordpress.com NAA4E Architecting .NET Solutions for the Enterprise