A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource...

45
A Microservices Journey Susanne Kaiser @suksr CTO at Just Software @JustSocialApps

Transcript of A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource...

Page 1: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

A Microservices JourneySusanne Kaiser

@suksr

CTO at Just Software@JustSocialApps

Page 2: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

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

Page 3: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Each Journey is Different

Team

Structure Skillset

Size

Journey

Affecting Circumstances

Page 4: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Each Journey is Different

Team

Structure Skillset

Size

Journey

Legacy

Maintenance effort

Runtime environment

Affecting Circumstances

Page 5: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Each Journey is Different

Team

Structure Skillset

Size

Journey

Legacy

Maintenance effort

Runtime environment

Strategy

New Features Timeline / Milestones

Affecting Circumstances

Page 6: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Background

JUST DRIVE JUST CONNECT JUST LIST JUST WIKI

JUST PEOPLE JUST NEWS

JUST SOCIAL

Page 7: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

One teamSingle Unit

One collaboration product

One technology stack

At the BeginningA Monolith in Every Aspect

Page 8: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

BackgroundAfter an Evolving Time

Page 9: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

BackgroundAfter an Evolving Time

Productivity suffered

Page 10: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

BackgroundAfter an Evolving Time

Productivity suffered

Usability/UX suffered

Page 11: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

BackgroundAfter an Evolving Time

Productivity suffered

Usability/UX suffered

New features released slowly

Page 12: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

JUST DRIVE JUST CONNECT JUST LIST JUST WIKI

JUST PEOPLE JUST NEWS

JUST SOCIAL

BackgroundSeparate Collaboration Apps

Page 13: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

BackgroundSeparate, Autonomous Teams

Well-defined responsibilites

Page 14: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

BackgroundIn The Long Run

Organisation Product Software

Page 15: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

BackgroundOur Motivation for Microservices

Autonomous teams

Develop independently Deploy independentlyWork at different partsindependently

Scale independently

At different speed

Page 16: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Identify Bounded ContextsDecomposition Strategy

High cohesion within a service

Loose coupling between services

Page 17: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Identify Bounded ContextsDecomposition Strategy

High cohesion within a service

Loose coupling between services

Bounded Context

Related behaviour

Semantic boundaryaround domain model

Well-defined business function

Page 18: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Identify Bounded ContextsDecomposition Strategy

JUST DRIVE JUST CONNECT JUST LIST

JUST WIKIJUST PEOPLE JUST NEWS

Bounded Contexts

Page 19: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

JUST DRIVE

Decomposition StrategyCo-Existing Service From Scratch

Page 20: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

JUST DRIVE

Decomposition StrategyCo-Existing Service From Scratch

JUST PEOPLE

Page 21: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Decomposition StrategyCo-Existing Service From Scratch

owns documentstate

REST API

Application-Service

Domain-Model

DB AdapterMonolith

JUST DRIVE

Page 22: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Decomposition StrategyCo-Existing Service From Scratch

owns documentstate

owns profilestate

documentcreated by author

Monolith

REST API

Application-Service

Domain-Model

DB Adapter

Page 23: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

owns documentstate

owns profilestate Events

local copyof author

Message Broker

Decomposition StrategyCo-Existing Service From Scratch

REST API

Application-Service

Domain-Model

DB Adapter

Message BrokerAdapter

Monolithpublish

subscribe

Page 24: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

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 StrategyCo-Existing Service From Scratch

Page 25: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Incremental Top Down

Extracting Web App

Decomposition Strategy

Monolith

REST API

REST API

REST Client

Page 26: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Monolith

REST API

Extracting Business Logic

Application-Service

Domain-Model

DB Adapter

REST Client

Incremental Top DownDecomposition Strategy

Monolith usesextracted business logic

Page 27: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Monolith

Splitting Data Storage

Incremental Top DownDecomposition Strategy

REST API

Application-Service

Domain-Model

DB Adapter

Events

Message Broker

Message BrokerAdapter

publishsubscribe

Page 28: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Which One First?

vs.

Easy to Extract

Changing Frequently

Different Resource ConsumptionEarly experiences w/ Microservices

Greatest benefit after extraction

Decomposition Strategy

Page 29: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Cross-Cutting ConcernsAuthorization

JUST DRIVE JUST WIKI

Fine-grained authorization

Inter-service dependency

Page 30: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Cross-Cutting Concerns

I have a new service that needs authorization. Where isthe authz service I could use?

Not there, yet. Sorry!

Ok, then I am putting my codeto the place where authz handling exists … to the monolith.

Feeding the monolith Re-implementing authz w/ everynew service

Ok, then I am implementing authzin my local service.

Authorization

Page 31: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Cross-Cutting ConcernsHandle Them Early

Feeding the monolith

Re-implementing authz w/ everynew service

Handle Cross-Cutting Concerns Early

Page 32: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Cross-Cutting ConcernsAvoid A Distributed Monolith

Authz Service

Page 33: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Cross-Cutting ConcernsAvoid A Distributed Monolith

Authz Servicetranslate

One stable common contract

translate

translate

Page 34: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Service InteractionEvent-Driven / Request-Driven

command

query EventsMessage Broker

publish subscribe

command

query

Request-Driven Hybrid

EventsMessage Broker

publish subscribe

Event-Driven

Page 35: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

How To Manage Shared Data?Hybrid Model

Message Broker

REST API

Remote query directly to source

Events for notification

Page 36: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Event Driven State Transfer

Message Broker

Local copy of profile data

ProfileUpdatedEvent

How To Manage Shared Data?

Events for data duplication

Page 37: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Source Of TruthHow 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

Page 38: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Messaging System Storage System Streaming Platform

Message Broker

Event Log Event Stream

Page 39: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

How To Manage Shared Data?Kafka Streams

Unbounded, ordered sequenceof data records

Key-value pairContinuouslyupdating

Page 40: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

How To Manage Shared Data?Kafka Streams

Kafka TopicLightweight embedded state store (disk-backed)

Service Running in the same processof Microservice

Loaded on startup of Microservice

Streams make data available wherever it’s needed

Page 41: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

How To Manage Shared Data?Kafka Streams

Kafka Streams API

join

filter

group by

aggregate

etc.

Changelog of state changesKStream 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→

Page 42: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

How To Manage Data?Materialized Views w/ Kafka Streams

KafkaTable for enrichment

Document Service

Stream REST API

Materialized View as State Store

Stream-Table-Join

Page 43: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

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

Page 44: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

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

Page 45: A Microservices Journey - GOTO Conference...Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Susanne Kaiser@suksr

CTO at Just Software@JustSocialApps