Top Banner
Serverless CQRS in Azure! Toon Vanhoutte https://be.linkedin.com/pub/toon-vanhoutte/6/276/84b
36

Serverless CQRS in Azure!

Jan 22, 2018

Download

Technology

BizTalk360
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: Serverless CQRS in Azure!

Serverless CQRS in Azure!

Toon Vanhoutte

https://be.linkedin.com/pub/toon-vanhoutte/6/276/84b

Page 2: Serverless CQRS in Azure!

Toon Vanhoutte

Serverless CQRS in Azure!

Page 3: Serverless CQRS in Azure!

Nice to meet you

Toon Vanhoutte

Lead Architect @ Codit Belgium

Microsoft Azure MVP

@toonvanhoutte

toonvanhoutte.wordpress.com

www.linkedin.com/in/toon-vanhoutte

Page 4: Serverless CQRS in Azure!

Who we are

Customers Entities

2000 Belgium

2004 France

2013 Portugal

2016 Switzerland

2016 UK

2016 The Netherlands

2017 Malta

150worldwide

Page 5: Serverless CQRS in Azure!

The thing we do

Page 6: Serverless CQRS in Azure!

Agenda

• An Introduction to CQRS

• Serverless Technologies in Azure

• Use Case: Optimize a Webshop

• Conclusion

6

Page 7: Serverless CQRS in Azure!

An introduction to CQRS

Page 8: Serverless CQRS in Azure!

CRUD ArchitectureProven and simple design

Page 9: Serverless CQRS in Azure!

Command Query Responsibility SegregationDealing with complex domain models

Page 10: Serverless CQRS in Azure!

Command Query Responsibility SegregationDealing with high performing applications

Page 11: Serverless CQRS in Azure!

Commands vs Queries

Write

Reliable

Sync / Async

Transactional

Persistent

Commands Queries

Read

Volatile

Sync

Non Transactional

In Memory

Fast Fast

Page 12: Serverless CQRS in Azure!

Serverless in Azure

Page 13: Serverless CQRS in Azure!

Pizza as a Service

Page 14: Serverless CQRS in Azure!

14

Serverless Technology Options

Azure Functions

“Code triggered by events”

Azure Logic Apps

“Workflows triggered by events”

Azure Event Grid

“Serverless event routing service”

Azure Service Bus

“Reliable messaging platform”

Page 15: Serverless CQRS in Azure!

Pricing Model

Security

Runtime

Monitoring

Deployment

State

Networking

Connectivity

Exception Handling

Developer experience

Azure Functions Azure Logic Apps

Page 16: Serverless CQRS in Azure!

Azure Functions Azure Logic Apps

Preferred option for

complex synchronous

request/response calls.

Preferred option for

asynchronous fire-and-

forget messaging.

Azure Functions

perfectly extends

Azure Logic Apps.

Page 17: Serverless CQRS in Azure!

Command

Query

Report

TransferNotification

MeasurementAssignment

Job

UpdateRequest Trace

Handover

Azure Service Bus Azure Event Grid

© Clemens Vasters

Page 18: Serverless CQRS in Azure!

Azure Service Bus Azure Event Grid

Command

Query

ReportTransfer

Notification

MeasurementAssignment

Job

Update

Request

Trace

Handover

Passing Intents Reporting Facts

Mess

ag

ing Eve

ntin

g

Discrete

Series

© Clemens Vasters

Page 19: Serverless CQRS in Azure!

Azure Service Bus Azure Event Grid

Passing Intents Reporting Facts

Mess

ag

ing Eve

ntin

g

Discrete

Series

“PriceUpdated”

“OpportunityWon”

“InvoiceBooked”

Temperature stream

Telemetry data

Audit trail

“CreateOrder”

“BookHotel”

“UpdateStock”

© Clemens Vasters

Page 20: Serverless CQRS in Azure!

Use Case

Page 21: Serverless CQRS in Azure!

Pizza Antonio

Find out how CQRS will save

Antonio’s business!

Page 22: Serverless CQRS in Azure!

Pizza Antonio

Website

€ 10€ 12€ 11

Submit

Query

Command

Page 23: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

GetProducts

CreateOrder

SQ

L D

ata

base

Very good pizza’s

Customers get errors when ordering pizza during peak hours

Page 24: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

GetProducts

CreateOrder

SQ

L D

ata

base

Customers don’t get any errors anymore

The orders don’t make it to the database, so no pizza

Page 25: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

GetProducts

CreateOrder

SQ

L D

ata

base

All orders make it to the database

Polling during quiet hours is rather expensive, so more expensive pizza’s

Page 26: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

GetProducts

CreateOrder

SQ

L D

ata

base

Cheaper polling mechanism, so again sharper prices

No flexible way to send order confirmations through email

Page 27: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

GetProducts

CreateOrder

SQ

L D

ata

base

Flexible extension points for e.g. emails

Two different URL’s and security keys for the website

Page 28: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

SQ

L D

ata

base

GetProducts

CreateOrder

Azu

re F

unct

ion P

roxy

Uniform API for website

Loading products on the website is extremely slow during peak hours

Page 29: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

SQ

L D

ata

base

GetProducts

CreateOrder

Azu

re F

unct

ion P

roxy

Fast responsive times on the website

No flexible way to update products on external food delivery services

Page 30: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

GetProducts

CreateOrder

SQ

L D

ata

base

Azu

re F

unct

ion P

roxy

Page 31: Serverless CQRS in Azure!

Pizza Antonio

Query

Co

mm

and

GetProducts

CreateOrder

SQ

L D

ata

base

Azu

re F

unct

ion P

roxy

Antonio happy

Customers happy

Page 32: Serverless CQRS in Azure!

Conclusion

Page 33: Serverless CQRS in Azure!

CQRS is a proven design pattern!It exists in many different variations

Azure Function Proxy

SQL Database

QueryCommand

Sentinet

SQL Database

QueryCommand

Azure API Mgmt

SQL Database

QueryCommand

Cache

Page 34: Serverless CQRS in Azure!

Lessons learned

Azure Functions Azure Event Grid

Consumption plan results

in cold starts, also for

function proxies!

Solution:

• Keep it warm (5 min)

• App Service Plan

• Pre-compiled

functions

Event Grid puts

responsibility for

sequencing at receive side!

Solution:

• Use it wisely

• Consider Azure Service

Bus if sequencing is

required

Page 35: Serverless CQRS in Azure!

Architectural Advise on CQRSDo not overengineer!

Performance

Flexibility

Scalability

Advantages

Idempotence

Resiliency

Eventual Consistency

Challenges

Complexity

Maintenance

Monitoring

Disadvantages

Apply CQRS carefully on specific parts of the solution!

Page 36: Serverless CQRS in Azure!

Thank you!Keep in touch.

@toonvanhoutte

toonvanhoutte.wordpress.com

www.linkedin.com/in/toon-vanhoutte