Watch your communication How communication drives design Uwe - - PowerPoint PPT Presentation

watch your communication
SMART_READER_LITE
LIVE PREVIEW

Watch your communication How communication drives design Uwe - - PowerPoint PPT Presentation

Watch your communication How communication drives design Uwe Friedrichsen (codecentric AG) GOTO Berlin Berlin, 13. November 2016 @ufried Uwe Friedrichsen | uwe.friedrichsen@codecentric.de | http://slideshare.net/ufried |


slide-1
SLIDE 1
slide-2
SLIDE 2

Watch your communication

How communication drives design

Uwe Friedrichsen (codecentric AG) – GOTO Berlin – Berlin, 13. November 2016

slide-3
SLIDE 3

@ufried

Uwe Friedrichsen | uwe.friedrichsen@codecentric.de | http://slideshare.net/ufried | http://ufried.tumblr.com

slide-4
SLIDE 4

The “one-size-fits-all” trap

slide-5
SLIDE 5

Standardization as a virtue

slide-6
SLIDE 6

We see that a lot

  • One programming language
  • One framework
  • One build system
  • One type of runtime unit
  • One data store
  • One type of database access
  • One application server
  • One ...
  • One communication paradigm
slide-7
SLIDE 7

Why are we doing it?

slide-8
SLIDE 8

Reducing complexity

  • Avoid intellectual overload
  • Easier to understand
  • Easier to change
  • Faster to change
  • Easier to operate
  • Less error-prone
  • Cheaper
slide-9
SLIDE 9

These are valid and important reasons …

slide-10
SLIDE 10

... but that is just one side of the coin

slide-11
SLIDE 11

The complexity of a solution
 must match
 the complexity of the problem to solve

slide-12
SLIDE 12

If your task is to build a box from pre-cut boards,


  • nly using a hammer might be adequate
slide-13
SLIDE 13

If your task is also to paint the box you just built,


  • nly having a hammer might be a problem …
slide-14
SLIDE 14

Now imagine building a whole house
 just with a hammer …

slide-15
SLIDE 15

Yet, in IT we often tend to build whole houses
 just with a hammer because boxes can be built with a hammer

slide-16
SLIDE 16

Complexity mismatch means

  • Increased accidental complexity
  • Harder to understand
  • Harder to change
  • Slower to change
  • Harder to operate
  • More error-prone
  • More expensive
slide-17
SLIDE 17

Complexity

Essential complexity Adds direct accidental complexity

Problem complexity Ideal solution complexity

Adds indirect accidental complexity

slide-18
SLIDE 18

Complexity

Problem complexity Overly complex solution

Increased accidental complexity

More “tooling” than needed to get the job done well

slide-19
SLIDE 19

Complexity

Problem complexity Over- simplified solution

Increased accidental complexity

Not enough “tooling” to get the job done well

slide-20
SLIDE 20

Overall Solution Complexity := Essential Problem Complexity + Solution Complexity Mismatch

Solution Complexity Mismatch a.k.a. Accidental Complexity Be aware that mismatch in both directions
 adds to overall solution complexity

slide-21
SLIDE 21

Complexity

Essential complexity

Problem complexity

Aim for the least complex solution


with respect to the problem you have to solve

(Yes, it is about trade-offs – as always in architecture)

slide-22
SLIDE 22

Communication paradigms

slide-23
SLIDE 23

Communication paradigms

  • Dimensions of communication
  • Synchronous vs. asynchronous
  • Request/response vs. message passing
  • Commands, Events and Documents
  • Sender/Receiver dependency
slide-24
SLIDE 24

Communication paradigms

  • Typical communication patterns
  • Synchronous request/response
  • Asynchronous commands


(with known receiver)

  • Asynchronous events


(without known receiver)

slide-25
SLIDE 25

The “synchronous request/response everywhere” trap

slide-26
SLIDE 26

Why are we doing it?

slide-27
SLIDE 27

Remember the “one-size-fits-all” trap?

slide-28
SLIDE 28

Yes, but why this paradigm?

slide-29
SLIDE 29

Why synchronous R/R?

  • “It’s how the internet works”
  • “The library support is better”
  • “It is easier to reason about”
  • Matches the way we consciously think
  • Matches the way we learned to do design
slide-30
SLIDE 30

Do not forget the other side of the coin

slide-31
SLIDE 31

The flipside of the coin

  • HTTP was designed for a specific use case
  • Access hypermedia content
  • Not an ubiquitous communication solution
  • The world outside a process is different
  • Non-determinism kills easy reasoning
  • Latency creep kills easy reasoning
  • Solution mismatch adds complexity
  • Compromises functional encapsulation
  • Changes and extensions become more complicated
  • Longer activation paths compromise robustness
slide-32
SLIDE 32

Designing communication

slide-33
SLIDE 33

An (invidious) example …

slide-34
SLIDE 34

Order fulfillment

slide-35
SLIDE 35

Let us begin with the well-known
 synchronous request/response design ...

slide-36
SLIDE 36

Order fulfillment

Initial version with limited functionality


  • Order includes
  • Items
  • Amounts
  • Price per item
  • T
  • tal price
  • Credit card payment
  • Only non-digital items
slide-37
SLIDE 37

Order Fulfillment
 Service Online Shop Payment
 Service Credit Card Provider Shipment
 Service Warehouse System

<Foreign Service> <Own Service> Credit Card Coordinate Warehouse
slide-38
SLIDE 38

Order fulfillment

Add coupons


  • Order additionally includes
  • Optional coupon ID
  • Optional remaining coupon value
  • Coupon is already charged against total price
  • Validate coupon
slide-39
SLIDE 39

Order Fulfillment
 Service Online Shop Payment
 Service Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management

Coupon Credit Card Coordinate Warehouse Coordinate

Credit Card Provider

slide-40
SLIDE 40

Order fulfillment

Add promotions


  • Order additionally includes
  • Optional promotion ID
  • Promotion is already applied to order
  • Notify Campaign Management System

about promotion usage

slide-41
SLIDE 41

Order Fulfillment
 Service Online Shop Payment
 Service Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management

Coupon

Campaign Management

Promotion Credit Card Coordinate Warehouse Coordinate

Credit Card Provider

slide-42
SLIDE 42

Order fulfillment

Add customer accounts


  • Order additionally includes
  • Payment type (Credit card/Account)
  • Charge customer account
slide-43
SLIDE 43

Order Fulfillment
 Service Online Shop Payment
 Service Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Accounts Receivables

Coordinate Warehouse

Credit Card Provider

Coupon Promotion Credit Card Coordinate
slide-44
SLIDE 44

Order fulfillment

Add PayPal


  • Order additionally includes
  • More payment types (Credit card/PayPal/Account)
  • Payment via PayPal
slide-45
SLIDE 45

Order Fulfillment
 Service Online Shop Payment
 Service Credit Card Provider Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management

Promotion

Campaign Management Account service Payment provider PayPal Accounts Receivables

Coupon Credit Card Coordinate Warehouse PayPal Coordinate
slide-46
SLIDE 46

Order fulfillment

Add digital music library


  • New shipment method
  • Activate music assets in digital music library
  • Notify customer via email including access link
  • Digital music library has its own API
slide-47
SLIDE 47

Order Fulfillment
 Service Online Shop Payment
 Service Credit Card Provider Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management

Promotion

Campaign Management Account service Payment provider PayPal Accounts Receivables Music Library E-Mail Server

Coupon Credit Card Coordinate Warehouse Coordinate Music Notify Cust. PayPal Coordinate
slide-48
SLIDE 48

Order fulfillment

Add digital video library


  • New digital shipment channel
  • Activate video assets in digital video library
  • Notify customer via email including access link
  • Digital video library has its own API
  • Different from the music library API
slide-49
SLIDE 49

Order Fulfillment
 Service Online Shop Payment
 Service Credit Card Provider Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management

Promotion

Campaign Management Account service Payment provider PayPal Accounts Receivables Music Library Video Library E-Mail Server

Coupon Credit Card Coordinate Warehouse Coordinate Assets Notify Cust. PayPal Coordinate
slide-50
SLIDE 50

Order fulfillment

Add e-book library


  • New digital shipment channel
  • Activate e-books in e-book library
  • Notify customer via email including access link
  • E-Book library has its own API
  • Different from the other asset library APIs
slide-51
SLIDE 51

Order Fulfillment
 Service Online Shop Payment
 Service Credit Card Provider Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management

Promotion

Campaign Management Account service Payment provider PayPal Accounts Receivables Music Library E-Book Library Video Library E-Mail Server

Coupon Credit Card Coordinate Warehouse Coordinate Assets Notify Cust. PayPal Coordinate
slide-52
SLIDE 52

Order fulfillment

Add bonus card


  • Order additionally includes
  • Optional bonus card ID
  • Potential discount is already applied to order
  • Notify Loyalty Management System about

customer purchase

slide-53
SLIDE 53

Order Fulfillment
 Service Online Shop Payment
 Service Credit Card Provider Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management

Promotion

Campaign Management

Loyalty

Account service Payment provider PayPal Loyalty Management Accounts Receivables Music Library E-Book Library Video Library E-Mail Server

Coupon Credit Card Coordinate Warehouse Coordinate Assets Notify Cust. PayPal Coordinate
slide-54
SLIDE 54

Order fulfillment

More requirements to come …

slide-55
SLIDE 55

Order Fulfillment
 Service Online Shop Payment
 Service Credit Card Provider Shipment
 Service Warehouse System

<Foreign Service> <Own Service>

Coupon Management

Promotion

Campaign Management

Loyalty

Account service Payment provider PayPal Loyalty Management Accounts Receivables Music Library E-Book Library Video Library E-Mail Server

Coupon Credit Card Coordinate Warehouse Coordinate Assets Notify Cust. PayPal Coordinate

Synchronous request/response – findings

“Divide and conquer” design

  • Tight service coupling
  • including cross-domain coupling
  • Long activation paths
  • Latency creep
  • Availability erosion
  • Underlying design assumption is 100% availability of all services used
  • Complex orchestration logic in services
  • including cross-service transactions
  • New downstream services require changes of upstream services
  • including knowledge about how to access downstream services in upstream services
slide-56
SLIDE 56

Let us repeat the design
 using asynchronous events ...

slide-57
SLIDE 57

Order fulfillment

slide-58
SLIDE 58

Order fulfillment

Initial version with limited functionality


  • Order includes
  • Items
  • Amounts
  • Price per item
  • T
  • tal price
  • Credit card payment
  • Only non-digital items
slide-59
SLIDE 59

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Credit Card Service Warehouse Service Payment authorized

<Event>

Payment failed

slide-60
SLIDE 60

Order fulfillment

Add coupons


  • Order additionally includes
  • Optional coupon ID
  • Optional remaining coupon value
  • Coupon is already charged against total price
  • Validate coupon
slide-61
SLIDE 61

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Credit Card Service Warehouse Service Payment authorized

<Event>

Payment failed Coupon Management Coupon Service

slide-62
SLIDE 62

Order fulfillment

Add promotions


  • Order additionally includes
  • Optional promotion ID
  • Promotion is already applied to order
  • Notify Campaign Management System

about promotion usage

slide-63
SLIDE 63

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Credit Card Service Warehouse Service Promotion Service Coupon Service Payment authorized

<Event>

Payment failed

slide-64
SLIDE 64

Order fulfillment

Add customer accounts


  • Order additionally includes
  • Payment type (Credit card/Account)
  • Charge customer account
slide-65
SLIDE 65

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Credit Card Service Accounts Receivables Warehouse Service Promotion Service Coupon Service Payment authorized Payment failed

<Event>
slide-66
SLIDE 66

Order fulfillment

Add PayPal


  • Order additionally includes
  • More payment types (Credit card/PayPal/Account)
  • Payment via PayPal
slide-67
SLIDE 67

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Credit Card Service Accounts Receivables PayPal PayPal Service Warehouse Service Promotion Service Coupon Service Payment authorized Payment failed

<Event>
slide-68
SLIDE 68

Order fulfillment

Add digital music library


  • New shipment method
  • Activate music assets in digital music library
  • Notify customer via email including access link
  • Digital music library has its own API
slide-69
SLIDE 69

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Credit Card Service Accounts Receivables Music Library E-Mail Server PayPal PayPal Service Warehouse Service Promotion Service Coupon Service Music Library Service Notification Service Payment authorized Digital asset provisioned Payment failed

<Event>
slide-70
SLIDE 70

Order fulfillment

Add digital video library


  • New digital shipment channel
  • Activate video assets in digital video library
  • Notify customer via email including access link
  • Digital video library has its own API
  • Different from the music library API
slide-71
SLIDE 71

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Credit Card Service Accounts Receivables Music Library Video Library E-Mail Server PayPal PayPal Service Warehouse Service Promotion Service Coupon Service Music Library Service Video Library Service Notification Service Payment authorized Digital asset provisioned Payment failed

<Event>
slide-72
SLIDE 72

Order fulfillment

Add e-book library


  • New digital shipment channel
  • Activate e-books in e-book library
  • Notify customer via email including access link
  • E-Book library has its own API
  • Different from the other asset library APIs
slide-73
SLIDE 73

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Credit Card Service Accounts Receivables Music Library E-Book Library Video Library E-Mail Server PayPal PayPal Service Warehouse Service Promotion Service Coupon Service Music Library Service Video Library Service E-Book Library Service Notification Service Payment authorized Digital asset provisioned Payment failed

<Event>
slide-74
SLIDE 74

Order fulfillment

Add bonus card


  • Order additionally includes
  • Optional bonus card ID
  • Promotion is already applied to order
  • Notify Loyalty Management System about

customer purchase

slide-75
SLIDE 75

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Credit Card Service Loyalty Management Accounts Receivables Music Library E-Book Library Video Library E-Mail Server PayPal PayPal Service Warehouse Service Promotion Service Bonus Card Service Coupon Service Music Library Service Video Library Service E-Book Library Service Notification Service Payment authorized Digital asset provisioned Payment failed

<Event>
slide-76
SLIDE 76

And how do we figure out if a business transaction eventually completes?

slide-77
SLIDE 77

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Credit Card Service Loyalty Management Accounts Receivables Music Library E-Book Library Video Library E-Mail Server PayPal PayPal Service Warehouse Service Promotion Service Bonus Card Service Coupon Service Music Library Service Video Library Service E-Book Library Service Notification Service Order fulfillment supervisor Payment authorized Digital asset provisioned Payment failed

<Event> Track flow of events. Reschedule events in case of failure Services are responsible to eventually succeed
  • r fail for good, usually incorporating a
supervision/escalation hierarchy for that
slide-78
SLIDE 78

Order confirmed Online Shop Credit Card Provider Warehouse System

<Foreign Service> <Own Service>

Coupon Management Campaign Management Account service Credit Card Service Loyalty Management Accounts Receivables Music Library E-Book Library Video Library E-Mail Server PayPal PayPal Service Warehouse Service Promotion Service Bonus Card Service Coupon Service Music Library Service Video Library Service E-Book Library Service Notification Service Payment authorized Digital asset provisioned Payment failed

<Event>

Order fulfillment supervisor

Track flow of events Reschedule events in case of failure Services are responsible to eventually succeed
  • r fail for good, usually incorporating a
supervision/escalation hierarchy for that

Asynchronous events – findings

“Go with the flow” design

  • Services and domains decoupled
  • Very short activation paths
  • High responsiveness
  • High availability
  • No design assumptions about availability of services
  • Coordination via choreography
  • No central coordination and cross-service transactions
  • Instead functional compensation logic in external supervision service
  • New services can be integrated without touching existing services
  • Services only focus on their task (no knowledge about other services required)
slide-79
SLIDE 79

Didn’t we miss any special cases that
 would lead to very different findings?

slide-80
SLIDE 80

Some special cases

Synchronous request/response design

  • Current order status
  • E.g., pass status through call chain
  • Maybe additionally extend order fulfillment service

to store status in an status information database

  • Payment failed
  • E.g., stop processing in fulfillment service and send

back appropriate status to online shop

  • Cashing coupon failed
  • E.g., extend payment service to place task in desk
  • fficer’s inbox
  • Integrate new video library (different API)
  • Adapt shipment service to new API
  • Make sure not to disrupt other service aspects
slide-81
SLIDE 81

Some special cases

Asynchronous events design

  • Current order status
  • E.g., track events with a new service and store


them in an status information database

  • Payment failed
  • E.g., track dedicated event with a new service


that notifies customer and/or online shop

  • Cashing coupon failed
  • E.g., send out dedicated event that a new service

subscribes to

  • New service then places task in desk officer’s inbox
  • Integrate new video library (different API)
  • Implement new service
  • Replace existing service with new service
slide-82
SLIDE 82

Feels a lot like recurring patterns …

slide-83
SLIDE 83

What did we learn so far?

slide-84
SLIDE 84

Comparing the paradigms …

  • Decomposition
  • Vertically divide-and-conquer vs. horizontally go-with-the-flow
  • Coordination
  • Coordination logic/services and orchestration vs. event chains and choreography
  • Transactions
  • Built-in transaction handling vs. external supervision
  • Error handling
  • Built into service vs. escalation/supervision strategy
  • Separation of concerns
  • Multiple responsibilities service vs. single responsibility services
  • Encapsulation
  • Domain logic distributed across services vs. domain logic in one place
  • Complexity
  • A draw …
slide-85
SLIDE 85

Different communication paradigms lead to very different service designs

… which means different options to address a given problem

slide-86
SLIDE 86

Related areas and limitations

slide-87
SLIDE 87

Mixing communication paradigms

slide-88
SLIDE 88

Mixing paradigms

  • Always an option
  • Note the trade-off between design purity

and solution mismatch complexity

  • A (very) simple heuristic
  • Single functionality
  • All-or-nothing characteristic
  • Single domain

Ø Synchronous request/response

  • Multiple functionalities
  • Flow/Process characteristic
  • Multiple domains

Ø Asynchronous messaging

slide-89
SLIDE 89

What if the paradigm is fixed?

slide-90
SLIDE 90

Fixed paradigm

  • You can simulate other paradigms
  • E.g., simulate sync. r/r with async. messaging
  • E.g., simulate async. commands with sync. r/r
  • Will support the service design topic
  • Apart from that it is a (lame) compromise
slide-91
SLIDE 91

What about user interaction?

slide-92
SLIDE 92

User interaction

  • Interaction with user client is usually r/r
  • Use web sockets if available
  • Use the mediator pattern with timeouts
  • Could be implemented via a BFF service
  • Complement with processing status page
slide-93
SLIDE 93

Can we apply the same patterns inside process boundaries?

slide-94
SLIDE 94

Inside process boundaries

  • Have the process context in mind
  • Without threads
  • If your downstream call dies, you are also dead
  • Usually synchronous r/r is appropriate
  • Otherwise single-threaded scheduler is needed
  • With threads
  • “Multi-process light”
  • Better multi-threading resilience possible
  • More design options
slide-95
SLIDE 95

Wrap-up

  • The one-size-fits-all trap
  • Communication paradigms
  • The synchronous-r/r-everywhere trap
  • Designing communication
  • Influence on service design

Different communication paradigms
 lead to very different service designs

slide-96
SLIDE 96

There is no “one-size-fits-all” solution

slide-97
SLIDE 97

@ufried

Uwe Friedrichsen | uwe.friedrichsen@codecentric.de | http://slideshare.net/ufried | http://ufried.tumblr.com

slide-98
SLIDE 98
slide-99
SLIDE 99