Slide 1

Slide 1 text

Events, Workflows, Sagas? Keep Your Event-driven Architecture Sane. 1

Slide 2

Slide 2 text

In 2008, a large German publishing company announced that they’ll switch their IT to Apple Computers. 2

Slide 3

Slide 3 text

In 2008, a large German publishing company announced that they’ll switch their IT to Apple Computers. Somewhere down in the press statement, it read “the desktop computers will run Windows XP or Vista”. 3

Slide 4

Slide 4 text

4

Slide 5

Slide 5 text

5

Slide 6

Slide 6 text

6

Slide 7

Slide 7 text

7

Slide 8

Slide 8 text

So what have we looked at so far? Implementing a workflow by: - Making one service the coordinator, or - Using a workflow engine for coordination, and - Implementing a saga (can be done with either of the above) What do all approaches have in common? 8

Slide 9

Slide 9 text

- Introduce a complex piece of software - makes it harder to run, change, test - Introduce a split responsibility - Are not event-driven 9

Slide 10

Slide 10 text

Technical complexity: - Must be able to resume after crash - Must be able to handle timeouts - Must be distributed to avoid single point of failure - Needs distributed coordination (stateful) - (Some of) your business logic is now in a YAML or XML file 10

Slide 11

Slide 11 text

Organizational complexity: - Business logic is split - Error handling is split, leading to reduced clarity of responsibility if something goes wrong 11

Slide 12

Slide 12 text

12

Slide 13

Slide 13 text

13

Slide 14

Slide 14 text

14

Slide 15

Slide 15 text

Q: So how to implement complex workflows over multiple microservices? A: Don’t. Instead, break up the workflow. To match actual event driven architecture. Monolith -> Microservices Workflow -> Microworkflows 15

Slide 16

Slide 16 text

16

Slide 17

Slide 17 text

17

Slide 18

Slide 18 text

Q: But what about visibility of the end-to-end process? A: Don’t mix control and observability! 18

Slide 19

Slide 19 text

19

Slide 20

Slide 20 text

But what about timeouts? - flaky connections, retries - within service - processing times - SLA - service needs to scale, e.g. based on consumer lag - overall process - observer 20

Slide 21

Slide 21 text

But what about error handling? Errors must be handled within a service. The service gives a promise. This is a fundamental decoupling in event-driven architecture. 21

Slide 22

Slide 22 text

Surely, this only works for unrealistic, simplistic examples. No, it’s just much harder to fit it on slides in a non-confusing way. 22

Slide 23

Slide 23 text

Image: https://blog.codecentric.de/wer-microservices-richtig-macht-braucht-keine-workflow-engine-und-kein-bpmn 23

Slide 24

Slide 24 text

Image: https://blog.codecentric.de/wer-microservices-richtig-macht-braucht-keine-workflow-engine-und-kein-bpmn 24

Slide 25

Slide 25 text

Technicalities are not the problem, it’s a mindset issue. Think Promises. Enjoy the organizational clarity that it produces. 25

Slide 26

Slide 26 text

Think Unix Philosophy 1. Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new "features". 2. Expect the output of every program to become the input to another, as yet unknown, program. ... 26

Slide 27

Slide 27 text

Think reducing complexity, not managing it. https://twitter.com/bitfield/status/1411731604335214592?ref_src=twsrc%5Etfw 27

Slide 28

Slide 28 text

Think Agile. And then putting SAFE on top of it. 28

Slide 29

Slide 29 text

29

Slide 30

Slide 30 text

Orchestration vs. Choreography While these terms might be fitting to describe the concepts, most comparisons are not useful, but based on some folkloristic concerns (e.g. taking a workflow as given, not as something that is designed and can be changed). Hence I tried to avoid them. 30

Slide 31

Slide 31 text

Workflows are useful tools. Workflow engines too, probably. But not for implementing complex workflows on top of Microservices. That use case shouldn’t exist. Consider going event-driven instead. Break the workflow down into microworkflows. 31

Slide 32

Slide 32 text

People are quick to jump to sagas and workflow engines! - Is it someone who’s familiar with it, but not with EDA, and is scared to leave their comfort zone? - Is it someone who wants to sell you something? - Is it someone who really understands EDA, and what you want to achieve, and, after considering all trade-offs, gives genuine, well-founded advice? 32

Slide 33

Slide 33 text

Summary: Workflows and Sagas are at odds with event driven architecture. If you really want to get the benefits of event-driven architecture, go all-in, don’t impose an orchestrator on top of it. Keep your event-driven architecture sane. 33

Slide 34

Slide 34 text

Thank you! Mastodon https://social.tchncs.de/@lutzhuehnken Twitter https://twitter.com/lutzhuehnken Blog https://www.reactivesystems.eu/ 34