Effective Microservices Design using Events and Event Sourcing

Embed Size (px)

Citation preview

Effective Microservice Design

go-micro.services LOGoCreated with Sketch.

David Dawson

CEO GoMicro.Services
(and Simplicity Itself)

[email protected]

@davidthecoder

go-micro.services LOGoCreated with Sketch.

What is Design?

What is Architecture?

ArchitecturevsDesign

Limitless OptionsFor Design

Only a few Architectures

What is Architecture?

Not the solution!

An approach to solving the problem.

Tools to engage the world

Sounds familiar.

ArchitectureIs Philosophy

h

What is yourPhilosophy?

Ask the audience.

One big one.

MicroservicesPhilosophy?

Some say XXX

This is what we are going to discuss!

Understand a man by walking in his shoes

The path to Microservices

Flick through the pack of cards

The path to Microservices

Flick through the pack of cards

This Sucks

Flick through the pack of cards

What are Microservices?

Isolation!

AspirationEvolutionAbility to change

Isolation

Aspiration

Dan North

Bounded/ Centred Community

Microservicesare not about design

Dan North

Bounded/ Centred Community

What will makeMicroservicesAwesome?

Ask the audience.

One big one.

Mid 2014 .

Ask the audience.

One big one.

Mid 2014 .

Ask the audience.

One big one.

Mid 2014 .

One inescapable conclusion...

Same mistakesSame pain..

other design disciplinesapply below

Same mistakesSame pain..

The brave new world ofDDD Microservices

Ask the audience.

One big one.

What do we care about?

Pull out cards!

Throw them away!

Events

Ask the audience.

One big one.

Events

The One True Ubiquitous Language

Ask the audience.

One big one.

Events

The Stream is theOnly Truth that Matters

Ask the audience.

One big one.

MessagingIs Cool

HTTP is ok.

Event SourcedMicroservices

Ask the audience.

One big one.

Event SourcedMicroservices

Upgrades!

Ask the audience.

One big one.

Event SourcedMicroservices

Replay!

Ask the audience.

One big one.

Entity

Ask the audience.

One big one.

Entity

Many Representations

Ask the audience.

One big one.

Ask the audience.

One big one.

HandWaving Consultant

Ask the audience.

One big one.

Real World ExampleTM

Ask the audience.

One big one.

Company Analysis

Ask the audience.

One big one.

Company Analysis

Social analysis

Anomoly Detection

Introspect anEnterprise

Ask the audience.

One big one.

Audient.ly

Ask the audience.

One big one.

Ask the audience.

One big one.

Groups'Source'PipelineEventStoreWordCloudMapView

GenderDetectionSentimentAnalysisEtc...

UsersEventStoreGatewayUsers

MicroservicemicroserviceMicroserviceEventStoreMicroserviceMicroservice

MicroservicemicroserviceMicroservice

MicroserviceEventStoreGatewayMicroservice

EventStore

EventStoreGateway

Tectonic platesAreas that change togetherHow can we figure this out?

FunctionEventStore

EventStoreGateway

Tectonic platesAreas that change togetherHow can we figure this out?

SourceFunctionEventStore

ServiceServiceService

EventStoreGateway

Tectonic platesAreas that change togetherHow can we figure this out?

ViewSourceFunctionEventStoreViewView

ServiceServiceService

EventStoreGateway

Tectonic platesAreas that change togetherHow can we figure this out?

ViewSourceFunctionEventStoreViewView

ServiceServiceService

FunctionEventStoreGatewayFunction

Tectonic platesAreas that change togetherHow can we figure this out?

ViewSourceFunctionEventStoreViewView

ServiceServiceService

FunctionEventStoreGatewayFunction

Tectonic platesAreas that change togetherHow can we figure this out?

Gateway?

Ask the audience.

One big one.

View

FunctionEventStoreViewView

ServiceServiceService

FunctionEventStoreGatewayFunction

Tectonic platesAreas that change togetherHow can we figure this out?

GatewayTectonic platesAreas that change togetherHow can we figure this out?

GatewayTectonic platesAreas that change togetherHow can we figure this out?

GatewayAdapt world views

Tectonic platesAreas that change togetherHow can we figure this out?

GatewayAdapt world views

EventsMessaging

HTTPREST

Tectonic platesAreas that change togetherHow can we figure this out?

What else?

Ask the audience.

One big one.

View

FunctionEventStoreViewView

ServiceServiceService

FunctionEventStoreGatewayFunction

Tectonic platesAreas that change togetherHow can we figure this out?

Function

FunctionFunctionFunction

Tectonic platesAreas that change togetherHow can we figure this out?

'Chatter'

SentimentAnalysisGenderDetectionEtc...

Tectonic platesAreas that change togetherHow can we figure this out?

Microservice

MicroserviceMicroserviceMIcroservice

Tectonic platesAreas that change togetherHow can we figure this out?

What else?

Ask the audience.

One big one.

View

FunctionsEventStoreViewView

ServiceServiceService

FunctionEventStoreGatewayFunction

Tectonic platesAreas that change togetherHow can we figure this out?

ViewViewViewGateway

Tectonic platesAreas that change togetherHow can we figure this out?

ViewViewViewGateway

Eventually Consistent

Tectonic platesAreas that change togetherHow can we figure this out?

ViewViewViewGateway

Eventually Consistent

No Database!

Tectonic platesAreas that change togetherHow can we figure this out?

ViewViewViewGateway

Eventually Consistent

No Database!

Totally Isolated

Tectonic platesAreas that change togetherHow can we figure this out?

Event Sourcing!

Ask the audience.

One big one.

ViewViewViewGateway

Ask the audience.

One big one.

ProductGateway

Ask the audience.

One big one.

ProductGateway

Ask the audience.

One big one.

RouterGateway

ProductProductProduct

Ask the audience.

One big one.

RouterGateway

ProductProductProduct

Event Store

Totally isolatedYet consistent

Upgrade?

Ask the audience.

One big one.

RouterGateway

ProductProductProduct

Event Store

Totally isolatedYet consistent

RouterGateway

ProductProductProduct

Event Store

ProductTotally isolatedYet consistent

RouterGateway

ProductProductProduct

Event Store

ProductREPLAYTotally isolatedYet consistent

RouterGateway

ProductProductProduct

Event Store

ProductREPLAY

Totally isolatedYet consistent

Scaling?

Ask the audience.

One big one.

Event Streams

Ask the audience.

One big one.

RouterGateway

ProductProductProduct

Totally isolatedYet consistent

RouterGateway

ProductTotally isolatedYet consistent

RouterGateway

Product

Totally isolatedYet consistent

RouterGateway

Product

Totally isolatedYet consistent

RouterGateway

Product

1 .. 200

Totally isolatedYet consistent

What does an event look like?

Totally isolatedYet consistent

ActionThe intent behind the event

What does an event look like?

Totally isolatedYet consistent

ActionThe intent behind the event

Event IDA unique identifier

What does an event look like?

Totally isolatedYet consistent

ActionThe intent behind the event

Event IDA unique identifier

Parent IDThe event that 'caused' this one

What does an event look like?

Totally isolatedYet consistent

ActionThe intent behind the event

Event IDA unique identifier

Parent IDThe event that 'caused' this one

Service IDThe service or process that created it

What does an event look like?

Totally isolatedYet consistent

ActionThe intent behind the event

Event IDA unique identifier

Parent IDThe event that 'caused' this one

Service IDThe service or process that created it

PayloadYour Stuff

What does an event look like?

Totally isolatedYet consistent

Fun stuffthis gives you

Ask the audience.

One big one.

Chains ofEvents

Ask the audience.

One big one.

Order Stream

Notification Stream

Payment Stream

Ask the audience.

One big one.

Order Stream

Notification Stream

Payment Stream

Ask the audience.

One big one.

Order Stream

Notification Stream

Payment Stream

Ask the audience.

One big one.

Order Stream

Notification Stream

Payment Stream

Ask the audience.

One big one.

Order Stream

Notification Stream

Payment Stream

Ask the audience.

One big one.

Ask the audience.

One big one.

Order Placed

Payment Taken

Email Sent

Email Sent

Ask the audience.

One big one.

Dependencies

Ask the audience.

One big one.

Dependencies

Order Placed

Payment Taken

Email Sent

Email Sent

Ask the audience.

One big one.

Dependencies

Order Placed Order Creation Service

Payment Taken Payment Processor

Email Sent Email Gateway

Email Sent Email Gateway

Ask the audience.

One big one.

Audit

Ask the audience.

One big one.

Audit

Order Placed

Payment Taken

Email Sent

Email Sent

Ask the audience.

One big one.

Audit

Order Placed User = X

Payment Taken

Email Sent

Email Sent

Ask the audience.

One big one.

Testing Microservices is Hard!

Ask the audience.

One big one.

Testing Microservices is Hard?

Ask the audience.

One big one.

Ask the audience.

One big one.

The Network

Ask the audience.

One big one.

Process Management in a Test

The Network

Ask the audience.

One big one.

Process Management in a Test

The Network

Coupling between services

Ask the audience.

One big one.

Process Management in a Test

The Network

Coupling between services

The Network

Ask the audience.

One big one.

Testing!

Order Placed

Payment Taken

Email Sent

Email Sent

Ask the audience.

One big one.

Testing!

Order Placed

Payment Taken

Email Sent

Email Sent

A TEST

Ask the audience.

One big one.

Testing!

Order Placed

Email Sent

A TEST

Mock Payment Service?Ask the audience.

One big one.

Order Stream

Notification Stream

Payment Stream

Ask the audience.

One big one.

Testing!

Order Placed

Payment Taken

Email Sent

Email Sent

A TEST

Ask the audience.

One big one.

Testing!

Order Placed

Payment Taken

Email Sent

Email Sent

Ask the audience.

One big one.

How can you do this?

Not the first time we've ridden the trail

Event StoreEvent DistributionProjectionsSecurityEvent chain materialisationClient replayCheckpointsScalingTestingSerialisationSchema ChangeService Upgrade..

Not the first time we've ridden the trail

Want to help us make it easy?

Not the first time we've ridden the trail

[email protected]

http://gomicro.services

Want to help us make it easy?

Not the first time we've ridden the trail

David Dawson

@davidthecoder

Questions?

TALK TO MUNIB!

David Dawson

@davidthecoder

Thanks!

http://www.slideshare.net/DavidDawson9

Con 2015

Stockholm - 5th/6th NovLondon - 9th/10th Nov

Next Time!

Deployment Options for Microservices4th November