+ All Categories
Home > Documents > Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze...

Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze...

Date post: 15-Jul-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
27
@allardbz Pragmatic Microservices with DDD, CQRS and Event Sourcing using Axon Framework Allard Buijze Founder & CTO, AxonIQ Creator of AxonFramework [email protected] @allardbz
Transcript
Page 1: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Pragmatic Microserviceswith DDD, CQRS and Event Sourcing

using Axon Framework

Allard BuijzeFounder & CTO, AxonIQ

Creator of AxonFramework

[email protected]

@allardbz

Page 2: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Layered architecture

User Interface

Service Layer

Data Access Layer

Do

main

Mod

el

Page 3: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Service

Service

Service

Page 4: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

‘Normal’ SQL QUERY

22 JOINS 6 SUBQUERIES

Page 5: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Layered architecture

User Interface

Service Layer

Data Access Layer

Do

main

Mod

el

Method invocation Cache

Worker pools

Web

Cache

Session replication

Distributed 2nd level cache Query Cache

Page 6: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Page 7: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Page 8: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Source: http://www.sabisabi.com/images/DungBeetle-on-dung.JPG

Page 9: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

AxonFramework

Page 10: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Command Query Responsibility Segregation

Command

modelProjections

Client

Events

T: 1 mln / sResp: < 10 ms

T: Thr. 20 / sResp: < 100 ms

T: 10 mln / sResp. < 100 ms

T: 1 / sResp. < 10 ms

Page 11: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Events retain valueEvent Sourcing is an Architectural pattern in which Events are considered

the “source of truth”, based on which components (re)build their internal state.

Page 12: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

State storage Event Sourcing

Event Sourcing

• OrderCreated (id: 123)

• ItemAdded (2x Deluxe Chair, €399)• ItemRemoved (1x Deluxe Chair, €399)• OrderConfirmed

• OrderShipped

• OrderCancelledByUser

• ReturnShipmentReceived

• id: 123

• items

– 1x Deluxe Chair - € 399• status: return shipment rcvd

Page 13: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

The value of Event Sourcing• Audit trail

• Analytics

• Improve modeling

• Given-when-testing

• …

Page 14: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

The power of…

Not now

Page 15: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Event Sourcing

Live coding…

Page 16: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Monoliths

St Breock Downs Monolith - www.cornwalls.co.uk

Page 17: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Microservices vs Monoliths

Microservices system

Almost all the cases where I've heard of a system that was built as a

microservice system from scratch, it has ended up in serious trouble.

Monoliths

Almost all the successful microservice stories have started with a

monolith that got too big and was broken up

Martin Fowler

Source: http://martinfowler.com/bliki/MonolithFirst.html

Page 18: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Are you tall enough?

Source: martinfowler.com/bliki/MicroservicePrerequisites.html

Page 19: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

“Noun Driven Design”

Page 20: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

“Entity Services”

Page 21: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Number of deployment units

Modula

rity

“Evil anti-modularity forces”

Page 22: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

$

Page 23: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Location transparency

A Component should not be aware, nor make any

assumptions, of the location of Components it

interacts with

A component should neither be aware of nor make any

assumptions about the location of components it interacts with.

Location transparency starts with good API design (but doesn’t end there)

Page 24: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Microservices Messaging

Commands Events Queries

Route to single handler

Use consistent hashing

Provides confirmation/result

Distribute to all logical handlers

Consumers express ordering req’sNo results

Route with load balancing

Sometimes scatter/gather

Provides result

"Event" and “Message" is not the same thing!

Page 25: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Distributing components

Live coding…

Page 26: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Rule #1 of distributed computing:

Don’t

Page 27: Pragmatic Event Driven Microservices...Pragmatic Event Driven Microservices Author Allard Buijze Created Date 6/6/2019 10:22:39 AM ...

@allardbz

Try it yourself• Sources:

• https://github.com/abuijze/bike-rental-demo (‘devdays’ branch)

• https://github.com/AxonFramework/AxonFramework

• Download Axon

• axoniq.io/download (includes quick-start-guide)


Recommended