In this talk, I address two topics.
The first topic is the "one size fits all" dogma that we see quite often in IT. I try to explain, why we do it but also what the pitfalls are and how oversimplified solution spaces lead to the same kind of accidental complexity when trying to solve a given business problem as overly complex solution spaces.
The second and core topic is the influence that a communication paradigm you use has on your functional design. Based on the observation that synchronous request/response in all its flavors is the usually used "one size fits all" communication paradigm, I use a real-life example to demonstrate how two different communication paradigms (synchronous request/response and asynchronous event-based communication) can lead to very different functional service designs - and that synchronous request/response not necessarily leads to the more appropriate functional design.
The bottom line of the talk is that you should not give up your design options prematurely in order to be able to find the best problem-solution fit and that the choice of the communication paradigm is a more important options than most people usually think it is.
As always the voice track is missing and therefore quite a bit of the information (or probably most of the information) contained in the talk. But hopefully the slides still give you some useful pointers.
5. 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
14. Yet, in IT we often tend to build whole housesâ¨
just with a hammer
because boxes can be built with a hammer
15. Complexity mismatch means
â˘âŻ Increased accidental complexity
â˘âŻ Harder to understand
â˘âŻ Harder to change
â˘âŻ Slower to change
â˘âŻ Harder to operate
â˘âŻ More error-prone
â˘âŻ More expensive
19. 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
22. Communication paradigms
â˘âŻ Dimensions of communication
â˘âŻ Synchronous vs. asynchronous
â˘âŻ Request/response vs. message passing
â˘âŻ Commands, Events and Documents
â˘âŻ Sender/Receiver dependency
23. Communication paradigms
â˘âŻ Typical communication patterns
â˘âŻ Synchronous request/response
â˘âŻ Asynchronous commandsâ¨
(with known receiver)
â˘âŻ Asynchronous eventsâ¨
(without known receiver)
28. 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
30. 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
34. Let us begin with the well-knownâ¨
synchronous request/response design ...
35. Order fulfillment
Initial version with limited functionalityâ¨
â˘âŻ Order includes
â˘âŻ Items
â˘âŻ Amounts
â˘âŻ Price per item
â˘âŻ Total price
â˘âŻ Credit card payment
â˘âŻ Only non-digital items
37. Order fulfillment
Add couponsâ¨
â˘âŻ Order additionally includes
â˘âŻ Optional coupon ID
â˘âŻ Optional remaining coupon value
â˘âŻ Coupon is already charged against total price
â˘âŻ Validate coupon
39. Order fulfillment
Add promotionsâ¨
â˘âŻ Order additionally includes
â˘âŻ Optional promotion ID
â˘âŻ Promotion is already applied to order
â˘âŻ Notify Campaign Management System
about promotion usage
41. Order fulfillment
Add customer accountsâ¨
â˘âŻ Order additionally includes
â˘âŻ Payment type (Credit card/Account)
â˘âŻ Charge customer account
44. 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
45. 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
46. 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
47. 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
48. 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
49. 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
50. 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
51. 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
52. 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
54. 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
55. Let us repeat the designâ¨
using asynchronous events ...
57. Order fulfillment
Initial version with limited functionalityâ¨
â˘âŻ Order includes
â˘âŻ Items
â˘âŻ Amounts
â˘âŻ Price per item
â˘âŻ Total price
â˘âŻ Credit card payment
â˘âŻ Only non-digital items
58. Order confirmed
Online Shop
Credit Card
Provider
Warehouse
System
<Foreign Service>
<Own Service>
Credit Card
Service
Warehouse
Service
Payment authorized
<Event>
Payment failed
59. Order fulfillment
Add couponsâ¨
â˘âŻ Order additionally includes
â˘âŻ Optional coupon ID
â˘âŻ Optional remaining coupon value
â˘âŻ Coupon is already charged against total price
â˘âŻ Validate coupon
60. 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
61. Order fulfillment
Add promotionsâ¨
â˘âŻ Order additionally includes
â˘âŻ Optional promotion ID
â˘âŻ Promotion is already applied to order
â˘âŻ Notify Campaign Management System
about promotion usage
62. 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
63. Order fulfillment
Add customer accountsâ¨
â˘âŻ Order additionally includes
â˘âŻ Payment type (Credit card/Account)
â˘âŻ Charge customer account
64. 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>
66. 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>
67. 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
68. 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>
69. 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
70. 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>
71. 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
72. 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>
73. 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
74. 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>
75. And how do we figure out if a business
transaction eventually completes?
76. 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
or fail for good, usually incorporating a
supervision/escalation hierarchy for that
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
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
or 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)
78. Didnât we miss any special cases thatâ¨
would lead to very different findings?
79. 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
officerâs inbox
â˘âŻ Integrate new video library (different API)
â˘âŻ Adapt shipment service to new API
â˘âŻ Make sure not to disrupt other service aspects
80. 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
83. 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 âŚ
89. 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
91. 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
92. Can we apply the same patterns
inside process boundaries?
93. 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
94. 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