productivity *and* cost-effectiveness withddd · • brookman’s ddd complexity: • 𝑓𝑖 =...

34
https://www.flickr.com/photos/beraldoleal/8681750288 Productivity * and * Cost - Effectiveness with DDD “Defying the Microservices DeathstarRaimond Brookman Principal Architect @raimondb

Upload: others

Post on 20-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Deze template bevat twee ontwerpen:

https://www.flickr.com/photos/beraldoleal/8681750288

Productivity *and*

Cost-Effectiveness with DDD“Defying the Microservices Deathstar”

Raimond Brookman

Principal Architect

@raimondb

Page 2: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Mainframe Client / Server N-Tier / CBD SOAEDA &

Microservices

Past Problems, where did we come from?

• Focus: Automate

essentials

• “Monopoly”

• Single Stack

• Sync/Async

• Batch

• Clustered

• Focus: Serving

the organization

• Decentralized

• ACID

• Single stack

• Sync

• Batch/Online

• Scale Up

• Focus: “Enabling the

Web”

• Decentralized

• 2PC

• Single Stack

• Sync

• Online

• Logic Scale Out,

Data Scale Up

• Focused on Data

Consistency & B2B

STP

• Centralized Design

• SPOT

• Web B2B standards

• Sync

• Online

• Scale Out

foundations

• Focused on Scaling &

Growth of #customers

• Decentralized (again)

• EC

• Polyglot (reality)

• Async

• Online

• Clustered, Avanced

Scale Out

@raimondb

Page 3: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• Decentralized

– Small units

– Clear goals, easier change

• Autonomy

– Independent choices (polyglot)

– Autonomous releases

• This is great, let’s scale it!

– Less dependencies and coordination

– Oh wait…..

Solution by Microservices

@raimondb

Page 4: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Dangers of large microservices ecosystems

Amazon Netflix

@raimondb

Page 5: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

“Pile of Rubble Architecture”

/ “Smaller is better”“Reuse is evil” Unmanaged

Emergence

Cause of Current Challenges

@raimondb

Page 6: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Smaller is Better?

Page 7: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

What is more complex?Aggregate

Autonomy Boundary

@raimondb

Page 8: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• Qualitative Measure:

– Scott Woodfield’s research (1979) An Experiment on Unit Increase in Problem Complexity

– Summarized by Robert Glass (2003) in his book Facts and Fallacies of Software Engineering

– Reformulated by Roger Sessions (2012) in the blog post The Equation every Enterprise Architect

Should Memorize – Roger Sessions

Glass’s Law:

For every 25% increase in problem complexity (F), there is a 100% increase in

complexity (C) of the software solution.

Measuring Complexity

@raimondb

Page 9: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• Session’s Summation:

– 𝑏𝑓𝑖 = number of functions inside a module

– 𝑐𝑛𝑖 = number of connections to other modules

• Brookman’s DDD Complexity:

• 𝑏𝑓𝑖 = number of Aggregates inside an Autonomy Boundary

• 𝑐𝑛𝑖 = number of distinct Aggregate-Bound Commands & Events dependencies to

other Autonomy Boundaries

Calculating complexity

𝐶 =

𝑖=1

𝑚

103.1 log(𝑏𝑓𝑖) + 103.1 log(𝑐𝑛𝑖)

@raimondb

Page 10: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Example: Fully Connected Aggregates

259

147147

147

147 147

147

60 60

𝐶 = 259 𝐶 = 887 𝐶 = 120

Monolithic

ContextMinimalized

contextsOptimized

contexts

@raimondb

Page 11: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Back to our first Question…

𝐶 = 631 𝐶 = 234 𝐶 = 158@raimondb

Page 12: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• YMMV on system complexity depending on connectedness

– Disclaimer: Formula needs to be tuned per organization

• To keep the system level complexity low:

– Minimize number of external connections per module

– Minimize number of aggregates per module

• Balancing act of Cohesion & Loose Coupling

– Components that must change in unison and / or evolve together should be co-located

in the same Autonomy Boundary

– This automatically leads to “clusters” of aggregates that have heavy functional

interdependencies

What do we learn from this?

@raimondb

Page 13: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• There a more reasons for deploying separate

services than functional autonomy

• The previous exercise was about

Autonomy Boundaries.

• Microservices – are inside an Autonomy Boundary

– have their own Deployment Boundary

– A Deployment Boundary contains 1+ Aggregates

• Complexity is mostly dependent on coordination,

which is hardest across Autonomy Boundaries

But I want to scale my services

independently!

Aggregate

Autonomy Boundary

Deployment Boundary

@raimondb

Page 14: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• Bounded Contexts allow for independent

models and Ubiquitous Language

• So it is an Autonomy Boundary

• I often see this confused with Deployment

Boundaries

• Pro Tip: follow Conway's Law and make

sure a Bounded Context is the

responsibility of a Single Team

So how does this fit to

Bounded Contexts?

Aggregate

Autonomy Boundary

Deployment Boundary

@raimondb

Page 15: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• Smaller is not always better

– Don’t just smash your monolith into a “Pile of Rubble”

• Clear Autonomy Boundaries are most important!

Managing Complexity Conclusions

@raimondb

Page 16: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Having a Wider

View

Finding the Business Domains

Page 17: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Event Storming

• Great for bottom-up analysis

• Helps to scope *your* Bounded Context

• Works well when in “Unknown territory”–E.g. Lean Start-up, new services

• Not so great for the Big Picture in larger

organizations

@raimondb

Page 18: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Service Operations

Business Capability Mapping : Domains

• Great for Big Picture

• Identify potential

extractable Sub

Domains

18

Client Engagement

Omni-channel Client Interaction

Payments FinancingInvestingSavings

Packaged Product Management

Development

Agreements

Execution

Advice Service Requests

SalesMarketingPackagedProduct Offering

portfolio pricing

Asset management

Finance HR ICT Facilities Legal Risk

ProductCombinations & options

Value Added ServicesProduct (concept)-Development

Management

Client Invest

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Online

Offine

Monitoring Monitoring Monitoring Monitoring

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Client Finance

Management

Monitoring

@raimondb

Page 19: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Service Operations

Business Capability Mapping : Domains

• Local Monitoring

Choices for Agility?

• A Common Analytics

Platform with Local

solutions?

• Or a separate Capability

offering services to

other Domains?

19

Client Engagement

Omni-channel Client Interaction

Payments FinancingInvestingSavings

Packaged Product Management

Development

Agreements

Execution

Advice Service Requests

SalesMarketingPackagedProduct Offering

portfolio pricing

Asset management

Finance HR ICT Facilities Legal Risk

ProductCombinations & options

Value Added ServicesProduct (concept)-Development

Management

Client Invest

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Online

Offine

Monitoring Monitoring Monitoring Monitoring

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Client Finance

Management

Monitoring

@raimondb

Page 20: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Service Operations

Business Capability Mapping : Domains

• Local Agreement

Management

Solutions?

• Or centralized?

20

Client Engagement

Omni-channel Client Interaction

Payments FinancingInvestingSavings

Packaged Product Management

Development

Agreements

Execution

Advice Service Requests

SalesMarketingPackagedProduct Offering

portfolio pricing

Asset management

Finance HR ICT Facilities Legal Risk

ProductCombinations & options

Value Added ServicesProduct (concept)-Development

Management

Client Invest

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Online

Offine

Monitoring Monitoring Monitoring Monitoring

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Client Finance

Management

Monitoring

@raimondb

Page 21: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Service Operations

Business Capability Mapping : Domains

• Local Client

Management?

• Or Central CRM?

• Where to register

– Touchpoints

– Contact Information

– Product/Services in Use

– Customer Satisfaction

21

Client Engagement

Omni-channel Client Interaction

Payments FinancingInvestingSavings

Packaged Product Management

Development

Agreements

Execution

Advice Service Requests

SalesMarketingPackagedProduct Offering

portfolio pricing

Asset management

Finance HR ICT Facilities Legal Risk

ProductCombinations & options

Value Added ServicesProduct (concept)-Development

Management

Client Invest

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Online

Offine

Monitoring Monitoring Monitoring Monitoring

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Client Finance

Management

Monitoring

@raimondb

Page 22: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Identifying Bounded Contexts with a CU-matrix

1. Plot Business Functions /

Capabilities

2. Plot Involved Aggregates

3. C : Creation/Commands

U: Used (Read or Events)

Aggregates / Business Objects

Bu

sin

ess F

un

ctio

ns

4. Shift rows and columns

collecting C’s together

5. Identify Bounded Contexts

Based on Cohesion and Loose

Coupling

@raimondb

Page 23: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• Typical current choice

• Tactical DDD focused

• “Process Task” Driven

• Too Little view on Big Picture

Central Both Local

How to Decide?

• Typical choice in “SOA era”

• Based on Data Integrity

• Too Little View on Process

• Too much generalization

• Strategic DDD focused

• Factor Aggregates based on

Both Data & Process

• Optimized Choice, multi-level

@raimondb

Page 24: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Corporate CustomerManagement

Used ServicesService Operations

24

Customer Engagement

Omni-channel Customer Interaction

Payments FinancingInvestingSavings

Packaged Product Management

Development

Agreements

Execution

Touchpoint

Advice Service Requests

SalesMarketingPackagedProduct Offering

Customer

portfolio

Contract Agreement

pricing

Asset management

Finance HR ICT Facilities Legal Risk

Data Analytics(monitoring)

ProductCombinations & options

Value Added ServicesProduct (concept)-Development

Management

Output Management

(execution)

Customer Invest

Management

Voorbeeld Informatiedomeinenmodel

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Development

Agreements

Execution

Management

Online

Offine

Smart Reuse by splitting local and corporate responsibilities

Monitoring Monitoring Monitoring Monitoring

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Online

Offine

Monitoring

Customer Finance

Management

Client Profile Client Profile Client Profile Client Profile

Payments AccountManagement

Packaged ProductManagement

Active Services Portfolio

Model Contract Agreement

Customer Payment

Preferences

Payment Contract Renewal

Other Opportunities

Page 25: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• Take off your Blinkers!

• Find your balance by Middle Out

• Strategic DDD

– Big Picture Bounded Contexts using Business Capability Maps

– “Top Down”

• Tactical DDD

– Refine Context splits & Boundaries using Event Storming

– “Bottom up”

Reuse Conclusions

@raimondb

Page 26: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Managing

Emergence

Page 27: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

@raimondb

Modularity Evolution

Core

ComponentsTransistor, Resistor, Capacitor

Generic ICsMemory, I/O, Shift Register

Application

Specific ICsHarddisk Controller

Microprocessor

Open Systems

ArchitectureTechnical Bus Architectures

Functional Interfacing Standards

(Graphics, Audio, Storage)

1947 1960s 1970s 1980s

3GL Language &

Compilers

C: 1970s

Packaged Library

Managers

Maven: 2004

NuGet: 2010

NPM: 2010

Packaged Subsystem

Managers

Docker: 2013

Standardized Infra & Functions

(Cloud)

Kubernetes: 2015

Limited Functional standards-25

-45 -45 -35

The Bad News:

IT is wildly running behind in delivering high-

level modularized solutions

The Good News:

We are starting to catch up

The tools are in place ☺

Page 28: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

– Managing complexity in Hardware

because of muti-level modularization

› Hiding internals

› Explicit Interface

› Good old OOP Practices

– Nature manages complexity by

repeating patterns (aka Fractals)

Repeating Patterns

@raimondb

Page 29: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• 2D “Single Level” Bounded Context

• Little OO Principles @ organization

scale

• 3D “Fractal” Bounded Contexts

• A Context has its own Language at

each Level

• Deeper levels can have more

specialized communications

Back to the Deathstars..

@raimondb

Page 30: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Se

rvic

e O

pe

ratio

ns

Payments AccountManagement

30

Cu

sto

me

r En

ga

ge

me

nt

Corporate CustomerManagement

Used Services

Touchpoint

Customer

Contract Agreement

Voorbeeld Informatiedomeinenmodel Multi-level Ubiquitous Language

Packaged ProductManagement

Active ServicesPortfolio

Model Contract Agreement

Customer Payment

PreferencesPayment Contract

Renewal

Show

Service

Contract

Template

Activate

Customer

Service

(Command)

Payment Account

Opened (Event)

Customer

Service

Activated (Event)

PaymentAccount

Open Payment

Account (Command)

Savings… Investing…

Adding new

services does

not ripple

Single and

combined

products

supported

Specific

Language

General

Language

Page 31: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• Business Capabilities for “Rough Boundaries”

• Define high level Ubiquitous Language

– Only Primary Business Concepts

• Refine with Event Storming

• (Re-)establish “external interface” every time

• With each new Bounded Context also try to establish parent Context /

Domain

But isn’t this BDUF?

@raimondb

Page 32: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

• “Fractalize” your Bounded

Contexts to manage

complexity

Take Aways

• Big Picture Analysis to

identify Balanced Reuse

• Smaller is not always

better

@raimondb

Page 33: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Questions?

[email protected]

@raimondb

Page 34: Productivity *and* Cost-Effectiveness withDDD · • Brookman’s DDD Complexity: • 𝑓𝑖 = number of Aggregates inside an Autonomy Boundary • 𝑛𝑖 = number of distinct

Thanks!

Come see us at our Booth for further discussions!

[email protected]

@raimondb