Event Driven Microservices The sense, the non-sense and a way - - PowerPoint PPT Presentation

event driven microservices
SMART_READER_LITE
LIVE PREVIEW

Event Driven Microservices The sense, the non-sense and a way - - PowerPoint PPT Presentation

Event Driven Microservices The sense, the non-sense and a way forward @allardbz Once upon a time @allardbz Universal BBC architecture Box Box Cylinder Source: Ted Neward @allardbz Source:


slide-1
SLIDE 1

@allardbz

Event Driven Microservices

The sense, the non-sense and a way forward

slide-2
SLIDE 2

@allardbz

Once upon a time…

slide-3
SLIDE 3

@allardbz

“Universal ‘BBC’ architecture”

Box Box Cylinder

Source: Ted Neward

slide-4
SLIDE 4

@allardbz

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

slide-5
SLIDE 5

@allardbz

Microservices to the rescue!

slide-6
SLIDE 6

@allardbz

Why microservices?

slide-7
SLIDE 7

@allardbz

Agility (Team) Scalabilty

slide-8
SLIDE 8

@allardbz

Agility Scalability Additional Complexity

slide-9
SLIDE 9

@allardbz

“Universal Microservices architecture”

slide-10
SLIDE 10

@allardbz

Noun Driven Design

Noun? → Service!

slide-11
SLIDE 11

@allardbz

Noun Driven Design

OrderService

slide-12
SLIDE 12

@allardbz

Noun Driven Design

CustomerService

slide-13
SLIDE 13

@allardbz

Noun Driven Design

ProductService

slide-14
SLIDE 14

@allardbz

Noun Driven Design

InventoryService

slide-15
SLIDE 15

@allardbz

Number of deployment units Modularity

“Evil anti-modularity forces”

slide-16
SLIDE 16

@allardbz

slide-17
SLIDE 17

@allardbz

Want to build microservices? Learn to build a decent monolith first!

slide-18
SLIDE 18

@allardbz

$

slide-19
SLIDE 19

@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)

slide-20
SLIDE 20

@allardbz

Events

slide-21
SLIDE 21

@allardbz

Service C Service B Service D Service A

slide-22
SLIDE 22

@allardbz

Service A Service C Service B Service D

Event

slide-23
SLIDE 23

@allardbz

“Event” all the things!

slide-24
SLIDE 24

@allardbz

Maslow’s Hammer

slide-25
SLIDE 25

@allardbz

Birmingham Screwdriver

slide-26
SLIDE 26

@allardbz

“Maslow Syndrome”

slide-27
SLIDE 27

@allardbz

Event-carried State Transfer Event Notification Event Sourcing

slide-28
SLIDE 28

@allardbz

‘Event-Driven’ Microservices

Need to know

  • rdered items

Order service OrderCreated → ItemAdded → ItemRemoved → OrderConfirmed →

slide-29
SLIDE 29

@allardbz

Or worse…

Shipping Service Order service OrderCreated →  InventoryConfirmed ReadyForShipping →  OrderShipped Payment service OrderPaid →  ReadyForPayment

slide-30
SLIDE 30

@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’s No results Route with load balancing Sometimes scatter/gather Provides result

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

slide-31
SLIDE 31

@allardbz

OrderConfirmed →

‘Event-Driven’ Microservices

Need to know

  • rdered items

Order service ItemAdded → ItemRemoved → OrderConfirmed → OrderCreated →  GetOrderDetails OrderDetails →

slide-32
SLIDE 32

@allardbz

Event Sourcing: the truth, the whole truth, nothing but the truth

slide-33
SLIDE 33

@allardbz

State storage Event Sourcing

Event Sourcing

id: 123 items 1x Deluxe Chair - € 399 status: return shipment rcvd OrderCreated (id: 123) ItemAdded (2x Deluxe Chair, €399) ItemRemoved (1x Deluxe Chair, €399) OrderConfirmed OrderShipped OrderCancelledByUser ReturnShipmentReceived

slide-34
SLIDE 34

@allardbz

Event Sourcing

Some smart analytics Order service OrderCreated → ItemAdded → ItemRemoved → OrderConfirmed →

slide-35
SLIDE 35

@allardbz

Business reasons Technical reasons

Why use event sourcing?

  • Auditing / compliance /

transparency

  • Data mining, analytics:

value from data

  • Guaranteed completeness of raised

events

  • Single source of truth
  • Concurrency / conflict resolution
  • Facilitates debugging
  • Replay into new read models (CQRS)
  • Easily capture intent
  • Deal with complexity in models
slide-36
SLIDE 36

@allardbz

The challenges

Dealing with increasing storage size Complex to implement “Event Thinking”

slide-37
SLIDE 37

@allardbz

“Event” all the things! Source

slide-38
SLIDE 38

@allardbz

Event store in context

Application Event store

Past events New events

  • Works well for processing changes on single

entities/aggregates (Commands)

  • Does not work well for generic queries
slide-39
SLIDE 39

@allardbz

CQRS

Command-Query Responsibility Segregation

Command Handler Event store

Past events New events

Projection database Query Handler

New events

Projection logic

Updates Selection criteria Data

slide-40
SLIDE 40

@allardbz

“CQRS” all the things?

slide-41
SLIDE 41

@allardbz

Service Service Service Service Service Service

slide-42
SLIDE 42

@allardbz

Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service Service

slide-43
SLIDE 43

@allardbz

Communication = Contract

slide-44
SLIDE 44

@allardbz

Service Service Service Service Service

slide-45
SLIDE 45

@allardbz

Bounded context

Explicitly define the context within which a model applies. Explicitly set boundaries in terms of team organization, usage within specific parts of the application, and physical manifestations such as code bases and database schemas. Keep the model strictly consistent within these bounds, but don’t be distracted or confused by issues outside.

slide-46
SLIDE 46

@allardbz

Service Service Service Service Service Service Service Service

slide-47
SLIDE 47

@allardbz

Service Service Service Service Anti-corruption layer Service

slide-48
SLIDE 48

@allardbz

slide-49
SLIDE 49

@allardbz

In closing….

slide-50
SLIDE 50

@allardbz

Consider commands and queries as much as events

slide-51
SLIDE 51

@allardbz

Sharing is caring

slide-52
SLIDE 52

@allardbz

Beware coupling across bounded contexts

slide-53
SLIDE 53

@allardbz

“Microservice Journey”

slide-54
SLIDE 54

@allardbz

Monolith first

slide-55
SLIDE 55

@allardbz

wax-on , wax-off!