serverless ddd

57
Serverless Domain-Driven Design At last some productivity Asher Sterkin [email protected] Serverless Meetup April 25, 2017, Tel-Aviv

Upload: asher-sterkin

Post on 21-Jan-2018

481 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Serverless ddd

Serverless Domain-Driven Design

At last some productivity

Asher [email protected]

Serverless Meetup April 25, 2017, Tel-Aviv

Page 2: Serverless ddd

About Myself● Close to 40 years of experience in the software technology field● VP Technology, Chief Technology Advisor Group, NDS (2010 - 2012)● Distinguished Engineer, Office of CTO, Cisco Engineering (2012 - 2016)● Today CTO at IRKI● Focusing on software product line strategy

○ Lean Startup○ Wardley Maps○ (Strategic) Domain-Driven Design○ Cynefin○ Promise Theory○ Serverless Architecture○ ...

Page 3: Serverless ddd
Page 4: Serverless ddd

Metallic Sage Green Luster,Opaque Metallic Matte

Galvanized SF Pink Blush,Opaque Galvanized Semi-Matte

Metallic Dark Raspberry Iris,Opaque Metallic Matte

Light Olive Luster,Opaque Metallic Matte

Page 5: Serverless ddd
Page 6: Serverless ddd

Serverless ←→ DDD● DDD & Microservices● Serverless → DDD

○ Strategic DDD○ Tactical DDD○ Serverless AI → DDD

● Serverless ← DDD● Serverless DDD → Productivity

Page 8: Serverless ddd

Key Messages

Page 9: Serverless ddd

Domain Model

Ubiquitous Language

Bounded Context

Permeable Context Boundaries Result in BBoM

Symptoms of Rotting Design

● Rigidity - hard to change● Fragility - easy to break● Immobility - hard to reuse● Viscosity - hard to do the right thing● Opacity - disorganized expression● ...

Page 10: Serverless ddd

10

4+1 View of Software Architecture

Conceptual Physical

Process View Deployment View

Logical View

Use-Case View

Implementation View

End-user Functionality

Programmers Software management

PerformanceScalabilityThroughput

System integratorsSystem topology

Delivery, installationcommunication

System engineering

Analysts/DesignersStructure

P. Krutchen, “Architectural Blueprints - The “4+1” View Model of Software Architecture

Page 11: Serverless ddd

11

4+1 View of Software Architecture

Conceptual Physical

Process View Deployment View

Logical View

Use-Case View

Implementation View

End-user Functionality

Programmers Software management

PerformanceScalabilityThroughput

System integratorsSystem topology

Delivery, installationcommunication

System engineering

Analysts/DesignersStructure

Bounded Context → Microservice

Page 12: Serverless ddd

Serverless → Strategic DDD

Page 14: Serverless ddd

Strategic Domain-Driven Design

Page 15: Serverless ddd

Strategic Domain-Driven DesignFashion Accessories

Page 16: Serverless ddd

Strategic Domain-Driven DesignFashion Accessories

Page 17: Serverless ddd

Strategic Domain-Driven DesignFashion Accessories

Page 18: Serverless ddd

Disorder

Page 19: Serverless ddd

Disorder

Page 20: Serverless ddd

Disorder

Page 21: Serverless ddd

Pull Up/Push Down

Pull up useful abstractions

Push down support and generic stuff; control

through OSS contributions

Fashion Accessories

There is no ideal core domain model

sitting and waiting to be discovered.

It’s more like attractor gradually emerging out of multiple “safe-to-fail” experimentations

Page 22: Serverless ddd

Strategic Domain-Driven Design

● Compute● Network● Storage● Intelligence

Serverless

● 2D Shape● 3D Shape● ...

Geometry

● Color● ...

Graphics

Microservice = CF Stack?

ERP, CRM, SCM, PLM, ECM, CAD, ...

Taxes

Shipment

Web Site

Inventory

....

Fashion Accessories

Page 23: Serverless ddd

Strategic Domain-Driven Design

● Compute● Network● Storage● Intelligence

Serverless BC

● 2D Shape● 3D Shape● ...

Geometry

● Color● ...

Graphics

Microservice = CF Stack?

ERP, CRM, SCM, PLM, ECM, ...

Taxes

Shipment

Web Site

Inventory

....

Fashion Accessories

Page 24: Serverless ddd

Strategic Domain-Driven Design

● Compute● Network● Storage● Intelligence

Serverless BC

● 2D Shape● 3D Shape● ...

Geometry

● Color● ...

Graphics

Microservice = CF Stack?

ERP, CRM, SCM, PLM, ECM, ...

Taxes

Shipment

Web Site

Inventory

....

Fashion Accessories

Page 25: Serverless ddd

Strategic Domain-Driven Design

● 2D Shape● 3D Shape● ...

Geometry

● Color● ...

Graphics

● Compute● Network● Storage● Intelligence

Serverless BC

Microservice = CF Stack?

ERP, CRM, SCM, PLM, ECM, ...

Taxes

Shipment

Web Site

Inventory

....

Fashion Accessories

...

Page 26: Serverless ddd

Context Map is the Key

● 2D Shape● 3D Shape● ...

Geometry

● Color● ...

Graphics

● Compute● Network● Storage● Intelligence

Serverless BC

Microservice = CF Stack?

ERP, CRM, SCM, PLM, ECM, ...

Taxes

Shipment

Web Site

Inventory

....

Fashion Accessories

...

ACLACL

ACL

Page 27: Serverless ddd

Emerging Core Domain so Far

Types

Components Products

Inventory Items Customers

Manufacturers

Vendors Catalog Items

Shapes

Colors

Pictures

Page 29: Serverless ddd

Amazon is Eating Software ...

valu

e ch

ain

evolutionG C P U

Video Service

AIaaS

FaaS

PaaS

IaaS

Recommendations

...

Cloud Native

Ability to build a Web Scale Application is not a differentiator anymore!

Page 30: Serverless ddd

Serverless Strategic DDD

Prefer utility AIaaS

Prefer product or utility SaaS

Major effort

Pull up useful abstractions

Proper timing for API

Push down support and generic stuff; control

through OSS contributions

Page 31: Serverless ddd

Serverless → Tactical DDD

Page 32: Serverless ddd

Bounded Context

Tactical DDD Patterns

Domain Model

Ubiquitous Language Nouns, Adjectives, Imperative Verbs, Interrogative Verbs, Perfect Tense Verbs

Entities, Values, Commands, Queries, Events, Aggregates, Repository, Computational Services, Factories, ACL, Saga (Process Manager)

Serverless Cloud Environment

Page 33: Serverless ddd

Repository

Strong Transaction Consistency + Invariant

DDD Aggregate and Repository

<<Aggregate Root>>

Entity

Entity Value

Value

Eventual Transaction Consistency

Storage

Command/ Query

Request Processor

Command or Query Requests

Domain Events

Page 34: Serverless ddd

(AWS) Serverless DDD Patterns● Repository

○ CRUD ○ CQRS○ CQRS/ES○ CQRS/ES IoT Scale

● Computation Service○ Function○ Batch○ Map/Reduce

● Saga (Process Manager)

Page 35: Serverless ddd

Default Serverless DDD Repository (CRUD)

DynamoDB Streams

Command/Query Handler

Domain Event Handler

Strong vs. Eventual Consistency

Bead ShapeBead ColorBeadProduct TypeComponent Type

Page 36: Serverless ddd

Serverless DDD Repository (CQRS)

DynamoDB Streams

Command Handler Query View Builder

Query Handler ● Ad-hoc vs. precomputed● Inter- vs. Intra Aggregate

Query View Store

SOT Store

● Command vs. Query Storage optimization

● Query interface complexity

Bead Color/Shape Compatibility

Page 37: Serverless ddd

Serverless DDD Repository (CQRS/ES)

DynamoDB Streams

Command Handler Projection Builders

Query Handler ● Ad-hoc vs. precomputed● Inter- vs. Intra Aggregate

Query View Store

Event Store

Snapshot Store

● Immutability● Auditing

Product SpecProduct/Component Inventory

Page 38: Serverless ddd

Event Store Patterns● State Change Events (git style)● Measurement/Observation (telemetry)● Transaction/Account/Entry (accounting)● Meaningful Domain Events

Page 39: Serverless ddd

Snapshot Store Patterns● Most Recent State● State Change History● Multiple Worlds

Page 40: Serverless ddd

Serverless DDD Repository (CQRS/ES IoT Scale)

Edge Command/Event

Handler

Cloud Command/Event

HandlerThing Event Stream

Thing Event Handlers

Thing Snapshot View

Thing Projection Builder

Thing Event Store

Page 41: Serverless ddd

Serverless DDD Computation Services

Command/Query/Event Handler Computation Service

Bead Color/Shape Permutations

Bead Color

Bead Shape

Bead Component

Most popular productsMost popular colors per countryMinimal inventory level per product...

Page 42: Serverless ddd

Serverless DDD Saga (Process Manager)

Product Picture Album Building

Raw Pictures Catalog Pictures

Product Catalog

Background Cleanup Color/Light Adjustments Resolution Transcoding

Page 43: Serverless ddd

Serverless AI → DDD

Page 44: Serverless ddd

ignore AI

Irrelevance

adopt AI

Wasted time and resources

Page 45: Serverless ddd

Serverless DDD AI Patterns● Pereferrial Adapters: audio, video, picture, text● Application Services: dynamic state machines● Command/Query Request Processors: classification, matching● Event Handlers: anomaly detection● Computation Services: analysis, generation, transformation, optimization● Batch Processing: feedback and learning

Page 46: Serverless ddd

Serverless AI ← DDD

Pereferrial Adapters Application Services

Dynamic State Machines

Application-level Stimulo

Domain Services

Command/Query Requests EventsRaw A/V/T Inputs

Dynamic Classifications

Anomaly Detection

Event Processors

Feedback and Training

Pinterest/Instagram/Facebook/Twitter Feedback ProcessingBest Earrings MatchBest Necklace Match

Historical Data

Page 47: Serverless ddd

Serverless → DDDWhat is Missing?

Page 48: Serverless ddd

Serverless → DDD Wish List● Support for Actor Model● Support for Reactive Programming● JavaScript, JSON and YAML are (cloud) machine-level languages - need something at higher

level● Simple modeling tool (lightweight UML)● Fully fledged IDE supporting above● Support for Semantic Maps (kind of AI service)

Page 49: Serverless ddd

Serverless ← DDD

Page 50: Serverless ddd

Serverless

Creating this mess from Lambda Functions would not make it better

Page 51: Serverless ddd

DDD for Serverless

Use DDD Strategic and Tactical patterns as Serverless Architecture organizing principles to prevent ending with just a distributed version of BBoM.

Page 52: Serverless ddd

One who increases flesh, increases worms; one who increases possessions, increases worry; one who increases wives, increases witchcraft; one who increases maidservants, increases promiscuity; one who increases man-servants, increases thievery;

Pirkey Avot Chapter 2/7 .מרבה בשר מרבה רימה. מרבה נכסים מרבה דאגה. מרבה נשים מרבה כשפיםמרבה שפחות מרבה זימה. מרבה עבדים מרבה גזל

Kohelet Chapter 1/18

18For in much wisdom is much vexation, and he who increases knowledge, increases pain.

יחִּכי ְּברֹב ָחְכָמה ָרב ָּכַעס ְויֹוִסיף ַּדַעת יֹוִסיף ַמְכאֹוב:

Page 53: Serverless ddd

Too Many Moving Parts

...

Page 54: Serverless ddd

DDD for Serverless

Treat ‘em all as Aggregate Repositories within the corresponding Bounded Context of Generic Infrastructure Sub-Domain

Page 55: Serverless ddd

At Last Some Productivity

Page 56: Serverless ddd

How to Measure Productivity?● Lines of Code - well known anti-pattern● Story Points - less well known anti-pattern (velocity is not productivity) ● Features - “feature train” (producing many features nobody needs)● Value - too much depends on Product Owner; not under direct control● Domain Insights - only domain experts could bring it → a lot of experimentation

“Software Development is a Learning Process. Running code is byproduct.”

A.Brandolini

Page 57: Serverless ddd

“Consensus is poisonous for innovation”

D. Snowden

The last slide