Domain Events in Distributed Architecture

51
Domain Events in Distributed Architecture Michał Łukaszewski /m_lukaszewski

Transcript of Domain Events in Distributed Architecture

Page 1: Domain Events in Distributed Architecture

Domain Events in Distributed Architecture

Michał Łukaszewski

/m_lukaszewski

Page 2: Domain Events in Distributed Architecture

How to pretend that our application is reliable and fast and still get paid

Page 3: Domain Events in Distributed Architecture

Basics

Reasons

Methods

Events

Dark places

Rules

Page 4: Domain Events in Distributed Architecture

Basics

Page 5: Domain Events in Distributed Architecture
Page 6: Domain Events in Distributed Architecture

Performance Budget0.1 sec – human response to changes

2 sec – impatience

3 sec – 30% leaves a page

10 sec - users forget what they want to do (a short-term memory feature)

Page 7: Domain Events in Distributed Architecture

GUI

Action

Domain A Domain B

Responder

Renderer

Page 8: Domain Events in Distributed Architecture

Reasons

Page 9: Domain Events in Distributed Architecture

Performance issues

Page 10: Domain Events in Distributed Architecture

Performance issues

Page 11: Domain Events in Distributed Architecture

Performance issues

Page 12: Domain Events in Distributed Architecture

Application integration

Page 13: Domain Events in Distributed Architecture

Premature optimization

Page 14: Domain Events in Distributed Architecture

Overengineering

https://twitter.com/ziobrando/status/741186560373186560

Page 15: Domain Events in Distributed Architecture

Methods

Page 16: Domain Events in Distributed Architecture

http://www.pc-freak.net/blog/vertical-horizontal-server-services-scaling-vertical-horizontal-hardware-scaling/

Bigger is better?

Page 17: Domain Events in Distributed Architecture

Optimization

Page 18: Domain Events in Distributed Architecture

3 rules of optimization

Extract bottleneck to a service

Don’t

Don’t yet

Measure before do anything

Page 19: Domain Events in Distributed Architecture

3 rules of optimization

voilà

Page 20: Domain Events in Distributed Architecture
Page 21: Domain Events in Distributed Architecture

Events

Page 22: Domain Events in Distributed Architecture

Calling remote services

Page 23: Domain Events in Distributed Architecture

Calling remote services

You know nothing about state of remote service

but you want to use it aspart of real-time processing

Page 24: Domain Events in Distributed Architecture

Async everything

Page 25: Domain Events in Distributed Architecture

Event is a fact from the past

Page 26: Domain Events in Distributed Architecture

Event cannot be ordered

UserCommandRegisteredAddBlogPost

BlogPostAddedSendNotification

Page 27: Domain Events in Distributed Architecture

Domain events

Domain event is something that happened that

domain experts care about.Wise anonymous

Page 28: Domain Events in Distributed Architecture

Domain events

And now what?

Confirmation of action has been sent

Page 29: Domain Events in Distributed Architecture

Dark places

Page 30: Domain Events in Distributed Architecture

What the heck can I answer to a user?

Page 31: Domain Events in Distributed Architecture

Receiving messages in a right order

Page 32: Domain Events in Distributed Architecture

Sending messages in a right order

Page 33: Domain Events in Distributed Architecture

Sending messages in a right order

Page 34: Domain Events in Distributed Architecture

Concurrency conflicts

https://speakerdeck.com/ulff/event-sourcing-in-php

Page 35: Domain Events in Distributed Architecture

Concurrency conflicts

• You have no idea where conflict will rise• But you have to handle it

Page 36: Domain Events in Distributed Architecture

Events sequence

When, how and how many times we should inform a user

about progress?

UserCommandRegisteredAddBlogPost

BlogPostAddedSendNotification

Page 37: Domain Events in Distributed Architecture

Complex event trigger Distributed Dependency Hell

Page 38: Domain Events in Distributed Architecture

Complex event trigger Distributed Dependency Hell

Page 39: Domain Events in Distributed Architecture

Who the heck sent this s..t?!

Page 40: Domain Events in Distributed Architecture

Who the heck sent this s..t?!

• How to confirm–A sender–If message was sent–Is data are valid

Page 41: Domain Events in Distributed Architecture

QoS

FIFO

Page 42: Domain Events in Distributed Architecture

QoS

• How to–Mark an event as important

*by type*–Mark an event as important

*because source*–Mark some events as important

*because business logic*

Page 43: Domain Events in Distributed Architecture

There is no „the right way”

Know your enemy.

Page 44: Domain Events in Distributed Architecture

Rules

Page 45: Domain Events in Distributed Architecture

#1

I don’t know• how many of you are listening• in what order you will finish your

job• what you will return (and when)

Page 46: Domain Events in Distributed Architecture

#2

Event is a fact, not a wish.

Page 47: Domain Events in Distributed Architecture

#3

Event (data) have to be small and serializable.

Page 48: Domain Events in Distributed Architecture

#4

Each event has its own source.

Page 49: Domain Events in Distributed Architecture

#5

Don't model an event for a specific handler

Page 50: Domain Events in Distributed Architecture

Thanks!

?

Page 51: Domain Events in Distributed Architecture

Credits• https://speakerdeck.com/mat3u/domain-events-czyli-jak-radzic-sobie-z-rzeczywistoscia• https://speakerdeck.com/ulff/event-sourcing-in-php• http://blog.best.net.pl/16-key-points-wydajnosc-w-budowaniu-aplikacji-internetowych/• https://www.linkedin.com/profile/portfolio?id=31205064&authType=name&authToken=YnLc&med

iaID=51178139&trk=landing_share• http://danielwhittaker.me/2014/09/29/handling-concurrency-issues-cqrs-event-sourced-system/