serverless ddd
TRANSCRIPT
Serverless Domain-Driven Design
At last some productivity
Asher [email protected]
Serverless Meetup April 25, 2017, Tel-Aviv
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○ ...
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
Serverless ←→ DDD● DDD & Microservices● Serverless → DDD
○ Strategic DDD○ Tactical DDD○ Serverless AI → DDD
● Serverless ← DDD● Serverless DDD → Productivity
Video, Slides
Key Messages
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● ...
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
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
Serverless → Strategic DDD
Strategic Domain-Driven Design
Vernon Vaughn, “Implementing Domain-Driven Design”
Strategic Domain-Driven Design
Strategic Domain-Driven DesignFashion Accessories
Strategic Domain-Driven DesignFashion Accessories
Strategic Domain-Driven DesignFashion Accessories
Disorder
Disorder
Disorder
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
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
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
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
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
...
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
Emerging Core Domain so Far
Types
Components Products
Inventory Items Customers
Manufacturers
Vendors Catalog Items
Shapes
Colors
Pictures
Amazon is Eating Software ...
valu
e ch
ain
evolutionG C P U
eTailer Service
AIaaS
FaaS
PaaS
IaaS
SCM
...
Web Scale Operation
New Service
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!
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
Serverless → Tactical 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
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
(AWS) Serverless DDD Patterns● Repository
○ CRUD ○ CQRS○ CQRS/ES○ CQRS/ES IoT Scale
● Computation Service○ Function○ Batch○ Map/Reduce
● Saga (Process Manager)
Default Serverless DDD Repository (CRUD)
DynamoDB Streams
Command/Query Handler
Domain Event Handler
Strong vs. Eventual Consistency
Bead ShapeBead ColorBeadProduct TypeComponent Type
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
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
Event Store Patterns● State Change Events (git style)● Measurement/Observation (telemetry)● Transaction/Account/Entry (accounting)● Meaningful Domain Events
Snapshot Store Patterns● Most Recent State● State Change History● Multiple Worlds
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
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...
Serverless DDD Saga (Process Manager)
Product Picture Album Building
Raw Pictures Catalog Pictures
Product Catalog
Background Cleanup Color/Light Adjustments Resolution Transcoding
Serverless AI → DDD
ignore AI
Irrelevance
adopt AI
Wasted time and resources
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
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
Serverless → DDDWhat is Missing?
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)
Serverless ← DDD
Serverless
Creating this mess from Lambda Functions would not make it better
DDD for Serverless
Use DDD Strategic and Tactical patterns as Serverless Architecture organizing principles to prevent ending with just a distributed version of BBoM.
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.
יחִּכי ְּברֹב ָחְכָמה ָרב ָּכַעס ְויֹוִסיף ַּדַעת יֹוִסיף ַמְכאֹוב:
Too Many Moving Parts
...
DDD for Serverless
Treat ‘em all as Aggregate Repositories within the corresponding Bounded Context of Generic Infrastructure Sub-Domain
At Last Some Productivity
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
“Consensus is poisonous for innovation”
D. Snowden
The last slide