A Microservices Journey
Susanne Kaiser
@suksr
CTO at Just Software
@JustSocialApps
Each Journey is Different
“People try to copy Netflix,
but they can only copy what they see.
They copy the results, not the process.”
Adrian Cockcroft, AWS VP Cloud Architect,
former Netflix Chief Cloud Architect
Each Journey is Different
Team
Structure Skillset
Size
Journey
Affecting Circumstances
Each Journey is Different
Team
Structure Skillset
Size
Journey
Legacy
Maintenance
effort
Runtime
environment
Affecting Circumstances
Each Journey is Different
Team
Structure Skillset
Size
Journey
Legacy
Maintenance
effort
Runtime
environment
Strategy
New Features Timeline / Milestones
Affecting Circumstances
Background
JUST DRIVE JUST CONNECT JUST LIST JUST WIKI
JUST PEOPLE JUST NEWS
JUST SOCIAL
One team
Single Unit
One collaboration product
One technology stack
At the Beginning
A Monolith in Every Aspect
Background
After an Evolving Time
Background
After an Evolving Time
Productivity suffered
Background
After an Evolving Time
Productivity suffered
Usability/UX suffered
Background
After an Evolving Time
Productivity suffered
Usability/UX suffered
New features released slowly
JUST DRIVE JUST CONNECT JUST LIST JUST WIKI
JUST PEOPLE JUST NEWS
JUST SOCIAL
Background
Separate Collaboration Apps
Background
Separate, Autonomous Teams
Well-defined responsibilites
Background
In The Long Run
Organisation Product Software
Background
Our Motivation for Microservices
Autonomous
teams
Develop independently Deploy independently
Work at different parts
independently
Scale independently
At different
speed
Identify Bounded Contexts
Decomposition Strategy
High cohesion within a service
Loose coupling between services
Identify Bounded Contexts
Decomposition Strategy
High cohesion within a service
Loose coupling between services
Bounded Context
Related behaviour
Semantic boundary
around domain model
Well-defined
business function
Identify Bounded Contexts
Decomposition Strategy
JUST DRIVE JUST CONNECT JUST LIST
JUST WIKIJUST PEOPLE JUST NEWS
Bounded Contexts
JUST DRIVE
Decomposition Strategy
Co-Existing Service From Scratch
JUST DRIVE
Decomposition Strategy
Co-Existing Service From Scratch
JUST PEOPLE
Decomposition Strategy
Co-Existing Service From Scratch
owns document
state
REST API
Application-Service
Domain-Model
DB Adapter
Monolith
JUST DRIVE
Decomposition Strategy
Co-Existing Service From Scratch
owns document
state
owns profile
state
document
created by
author
Monolith
REST API
Application-Service
Domain-Model
DB Adapter
owns document
state
owns profile
state Events
local copy
of author
Message Broker
Decomposition Strategy
Co-Existing Service From Scratch
REST API
Application-Service
Domain-Model
DB Adapter
Message Broker
Adapter
Monolith
publish
subscribe
DB Adapter
Message Broker
Adapter
Application-Service
Domain-Model
REST API
Domain-Event
Good approach in general,
but we did too many steps at once
New UI
New Business Logic
New Data Structure
=> Not optimal to start with
vs.
Decomposition Strategy
Co-Existing Service From Scratch
Incremental Top Down
Extracting Web App
Decomposition Strategy
Monolith
REST API
REST API
REST Client
Monolith
REST API
Extracting Business Logic
Application-Service
Domain-Model
DB Adapter
REST Client
Incremental Top Down
Decomposition Strategy
Monolith uses
extracted business logic
Monolith
Splitting Data Storage
Incremental Top Down
Decomposition Strategy
REST API
Application-Service
Domain-Model
DB Adapter
Events
Message Broker
Message Broker
Adapter
publish
subscribe
Which One First?
vs.
Easy to Extract
Changing Frequently
Different Resource
Consumption
Early experiences w/ Microservices
Greatest benefit
after extraction
Decomposition Strategy
Cross-Cutting Concerns
Authorization
JUST DRIVE JUST WIKI
Fine-grained authorization
Inter-service dependency
Cross-Cutting Concerns
I have a new service
that needs authorization. Where is
the authz service I could use?
Not there, yet. Sorry!
Ok, then I am putting my code
to the place where authz handling
exists … to the monolith.
Feeding the monolith
Re-implementing authz w/ every
new service
Ok, then I am implementing authz
in my local service.
Authorization
Cross-Cutting Concerns
Handle Them Early
Feeding the monolith
Re-implementing authz w/ every
new service
Handle Cross-Cutting Concerns Early
Cross-Cutting Concerns
Avoid A Distributed Monolith
Authz Service
Cross-Cutting Concerns
Avoid A Distributed Monolith
Authz Servicetranslate
One stable
common contract
translate
translate
Service Interaction
Request-Driven / Event-Driven
command
query Events
Message Broker
publish subscribe
command
query
Request-Driven Hybrid
Events
Message Broker
publish subscribe
Event-Driven
How To Manage Shared Data?
Hybrid Model
Message Broker
REST API
Remote query
directly to source
Events for notification
Event Driven State Transfer
Message Broker
Local copy of
profile data
ProfileUpdatedEvent
How To Manage Shared Data?
Events for data duplication
Source Of Truth
How To Manage Shared Data?
Internal source of truth
External source of truth
Multiple sources of truth Single source of truth
Events as first-class citizens
“Traditional” Event-Driven System Event Store
Event Log
Messaging System Storage System Streaming Platform
Message Broker
Event Log Event Stream
How To Manage Shared Data?
Kafka Streams
Unbounded, ordered sequence
of data records
Key-value pairContinuously
updating
How To Manage Shared Data?
Kafka Streams
Kafka Topic
Lightweight embedded state store (disk-backed)
Service
Running in the same process
of Microservice
Loaded on startup of
Microservice
Streams make data available wherever it’s needed
How To Manage Shared Data?
Kafka Streams
Kafka Streams API
join
filter
group by
aggregate
etc.
Changelog of state changes
KStream KTable
Snapshot of the latest
value for each key
Kafka Stream-Table Duality
(key1, value1), (key2, value2), (key 1, value 3) key1 value3→
key2 value2→
How To Manage Data?
Materialized Views w/ Kafka Streams
Kafka
Table for enrichment
Document Service
Stream
REST API
Materialized View as State Store
Stream-Table-Join
How To Manage Shared Data?
Event Streams as a Shared Source of Truth
Events for notification Events for data duplication
● Simple integration
● Remote query => increasing coupling
● Eliminating remote query =>
better decoupling
● Local copy => better autonomy
● Duplicating effort to maintain
local dataset
● Simple integration
● Remote query => increasing coupling
Event streams as a
shared source of truth
● Eliminating local copy => reduces
duplicating effort
● Pushes data to where it’s needed
● Increases pluggability
● Low barrier to entry for new
service
Start small One manageable step at a time
Lessons Learned
Handle cross-cutting concerns early
Avoid a distributed monolith Be aware of affecting circumstances
&
Each journey is different :)
Design event-driven & consider
event streams as shared source of truth
Susanne Kaiser
@suksr
CTO at Just Software
@JustSocialApps

A Microservices Journey - Susanne Kaiser

  • 1.
    A Microservices Journey SusanneKaiser @suksr CTO at Just Software @JustSocialApps
  • 2.
    Each Journey isDifferent “People try to copy Netflix, but they can only copy what they see. They copy the results, not the process.” Adrian Cockcroft, AWS VP Cloud Architect, former Netflix Chief Cloud Architect
  • 3.
    Each Journey isDifferent Team Structure Skillset Size Journey Affecting Circumstances
  • 4.
    Each Journey isDifferent Team Structure Skillset Size Journey Legacy Maintenance effort Runtime environment Affecting Circumstances
  • 5.
    Each Journey isDifferent Team Structure Skillset Size Journey Legacy Maintenance effort Runtime environment Strategy New Features Timeline / Milestones Affecting Circumstances
  • 6.
    Background JUST DRIVE JUSTCONNECT JUST LIST JUST WIKI JUST PEOPLE JUST NEWS JUST SOCIAL
  • 7.
    One team Single Unit Onecollaboration product One technology stack At the Beginning A Monolith in Every Aspect
  • 8.
  • 9.
    Background After an EvolvingTime Productivity suffered
  • 10.
    Background After an EvolvingTime Productivity suffered Usability/UX suffered
  • 11.
    Background After an EvolvingTime Productivity suffered Usability/UX suffered New features released slowly
  • 12.
    JUST DRIVE JUSTCONNECT JUST LIST JUST WIKI JUST PEOPLE JUST NEWS JUST SOCIAL Background Separate Collaboration Apps
  • 13.
  • 14.
    Background In The LongRun Organisation Product Software
  • 15.
    Background Our Motivation forMicroservices Autonomous teams Develop independently Deploy independently Work at different parts independently Scale independently At different speed
  • 16.
    Identify Bounded Contexts DecompositionStrategy High cohesion within a service Loose coupling between services
  • 17.
    Identify Bounded Contexts DecompositionStrategy High cohesion within a service Loose coupling between services Bounded Context Related behaviour Semantic boundary around domain model Well-defined business function
  • 18.
    Identify Bounded Contexts DecompositionStrategy JUST DRIVE JUST CONNECT JUST LIST JUST WIKIJUST PEOPLE JUST NEWS Bounded Contexts
  • 19.
  • 20.
    JUST DRIVE Decomposition Strategy Co-ExistingService From Scratch JUST PEOPLE
  • 21.
    Decomposition Strategy Co-Existing ServiceFrom Scratch owns document state REST API Application-Service Domain-Model DB Adapter Monolith JUST DRIVE
  • 22.
    Decomposition Strategy Co-Existing ServiceFrom Scratch owns document state owns profile state document created by author Monolith REST API Application-Service Domain-Model DB Adapter
  • 23.
    owns document state owns profile stateEvents local copy of author Message Broker Decomposition Strategy Co-Existing Service From Scratch REST API Application-Service Domain-Model DB Adapter Message Broker Adapter Monolith publish subscribe
  • 24.
    DB Adapter Message Broker Adapter Application-Service Domain-Model RESTAPI Domain-Event Good approach in general, but we did too many steps at once New UI New Business Logic New Data Structure => Not optimal to start with vs. Decomposition Strategy Co-Existing Service From Scratch
  • 25.
    Incremental Top Down ExtractingWeb App Decomposition Strategy Monolith REST API REST API REST Client
  • 26.
    Monolith REST API Extracting BusinessLogic Application-Service Domain-Model DB Adapter REST Client Incremental Top Down Decomposition Strategy Monolith uses extracted business logic
  • 27.
    Monolith Splitting Data Storage IncrementalTop Down Decomposition Strategy REST API Application-Service Domain-Model DB Adapter Events Message Broker Message Broker Adapter publish subscribe
  • 28.
    Which One First? vs. Easyto Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction Decomposition Strategy
  • 29.
    Cross-Cutting Concerns Authorization JUST DRIVEJUST WIKI Fine-grained authorization Inter-service dependency
  • 30.
    Cross-Cutting Concerns I havea new service that needs authorization. Where is the authz service I could use? Not there, yet. Sorry! Ok, then I am putting my code to the place where authz handling exists … to the monolith. Feeding the monolith Re-implementing authz w/ every new service Ok, then I am implementing authz in my local service. Authorization
  • 31.
    Cross-Cutting Concerns Handle ThemEarly Feeding the monolith Re-implementing authz w/ every new service Handle Cross-Cutting Concerns Early
  • 32.
    Cross-Cutting Concerns Avoid ADistributed Monolith Authz Service
  • 33.
    Cross-Cutting Concerns Avoid ADistributed Monolith Authz Servicetranslate One stable common contract translate translate
  • 34.
    Service Interaction Request-Driven /Event-Driven command query Events Message Broker publish subscribe command query Request-Driven Hybrid Events Message Broker publish subscribe Event-Driven
  • 35.
    How To ManageShared Data? Hybrid Model Message Broker REST API Remote query directly to source Events for notification
  • 36.
    Event Driven StateTransfer Message Broker Local copy of profile data ProfileUpdatedEvent How To Manage Shared Data? Events for data duplication
  • 37.
    Source Of Truth HowTo Manage Shared Data? Internal source of truth External source of truth Multiple sources of truth Single source of truth Events as first-class citizens “Traditional” Event-Driven System Event Store Event Log
  • 38.
    Messaging System StorageSystem Streaming Platform Message Broker Event Log Event Stream
  • 39.
    How To ManageShared Data? Kafka Streams Unbounded, ordered sequence of data records Key-value pairContinuously updating
  • 40.
    How To ManageShared Data? Kafka Streams Kafka Topic Lightweight embedded state store (disk-backed) Service Running in the same process of Microservice Loaded on startup of Microservice Streams make data available wherever it’s needed
  • 41.
    How To ManageShared Data? Kafka Streams Kafka Streams API join filter group by aggregate etc. Changelog of state changes KStream KTable Snapshot of the latest value for each key Kafka Stream-Table Duality (key1, value1), (key2, value2), (key 1, value 3) key1 value3→ key2 value2→
  • 42.
    How To ManageData? Materialized Views w/ Kafka Streams Kafka Table for enrichment Document Service Stream REST API Materialized View as State Store Stream-Table-Join
  • 43.
    How To ManageShared Data? Event Streams as a Shared Source of Truth Events for notification Events for data duplication ● Simple integration ● Remote query => increasing coupling ● Eliminating remote query => better decoupling ● Local copy => better autonomy ● Duplicating effort to maintain local dataset ● Simple integration ● Remote query => increasing coupling Event streams as a shared source of truth ● Eliminating local copy => reduces duplicating effort ● Pushes data to where it’s needed ● Increases pluggability ● Low barrier to entry for new service
  • 44.
    Start small Onemanageable step at a time Lessons Learned Handle cross-cutting concerns early Avoid a distributed monolith Be aware of affecting circumstances & Each journey is different :) Design event-driven & consider event streams as shared source of truth
  • 45.
    Susanne Kaiser @suksr CTO atJust Software @JustSocialApps