Cloud Design Pattern part1

Preview:

Citation preview

Cloud Design Patterns – part 1Masashi NarumotoAzureCAT patterns & practicesMicrosoft

Software design is..

Making engineering decisionsDealing with trade-off Critical when something goes wrong

Designing cloud applications

Cloud Design Patterns

http://aka.ms/cloud-design-patterns

Cache-asideSharding Materialized ViewEvent SourcingCQRS

Agenda

Cache-aside problem - DB becomes bottleneck

User Web Role

Which data to cache? when?

Scale-out

Cache

Database

Cache

Cache-aside solution

User Web Role

Database

Seeding or on-demandData consistencyType of data to cacheLifetime of the dataUpdating dataRead-through/Write-behind cache

Cache-aside – considerations

Sharding problem – limit of a single DB 

User Web site

(semi) static data

?

Database

Sharding problem – Limit of a single DB 

User Web site

?

Database

Sharding - SolutionShard key( static data field)

1. Lookup2. Range3. Hash

Need to rebalance

Sharding – Lookup

Pros:- Flexibility on routing- Less impact when rebalancingCons:- Table maintenance is not trivial

Sharding – Range

Pros:- Efficient mapping- Affinity to range queryCons:- Particular shard may become hot spot- Noisy neighbors issue

Sharding – Hash

Pros:- Even distribution- In-memory mappingCons:- Overhead in computing hash- Impact in rebalancing

Use with other partitioning strategyChoose the right sharding strategyKeep the right balance across shardsAvoid JOIN across shardsKeep the room for growth

Sharding design considerations

Materialized View problem inefficient query

# customers/revenue per product?

Materialized View solution

How/When update the view?Data consistency issueData transfer/calculationGood for restricted access or occasionally connected scenarioNG for frequently changing data

Materialized View design considerations

Event Sourcing problem  Limit of CRUD 

Collaborative domain

Web site Database

CreateReadUpdateDelete

Conflicting updatesNo history recordAuditing is difficult

Event Sourcing solution

Replay events to get the current valueGenerate snapshots for quick replayData consistency issueGood for task-based UING for simple domain or strong consistency scenario

Event Sourcing design considerations

CQRS problem – R/W mismatch

User Interface

Data Access

Business LogicEntity

Collaborative domain Schema

Scale-out strategyUser privilege

Commands

CQRS solution

Data Access

DTOsBusiness Logic

Query / View

Task-Specific Command

User Interface

Event sourcing

Materialized View

Data consistency issuesOnly for limited section of the systemOne team on write, another on readNG for simple domain

CQRS design considerations

Search for “CQRS Journey“

✔✔

✔✔

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Recommended