microservices lessons learned...microservices lessons learned cto at just software @justsocialapps...

48
Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr @suksr #VoxxedMicroservices

Upload: others

Post on 07-Oct-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Microservices Lessons Learned

CTO at Just Software@JustSocialApps

Susanne KaiserIndependent Tech Consultant

@suksr

@suksr#VoxxedMicroservices

Page 2: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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

@suksr#VoxxedMicroservices

Page 3: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Each Journey is Different

Team

Structure Skillset

Size

Journey

Affecting Circumstances

@suksr#VoxxedMicroservices

Page 4: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Each Journey is Different

Team

Structure Skillset

Size

Journey

Legacy

Maintenance effort

Runtime environment

Affecting Circumstances

@suksr#VoxxedMicroservices

Page 5: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Each Journey is Different

Team

Structure Skillset

Size

Journey

Legacy

Maintenance effort

Runtime environment

Strategy

New Features Timeline / Milestones

Affecting Circumstances

@suksr#VoxxedMicroservices

Page 6: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Background

JUST DRIVE JUST CONNECT JUST LIST JUST WIKI

JUST PEOPLE JUST NEWS

JUST SOCIAL

@suksr#VoxxedMicroservices

Page 7: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

One teamSingle Unit

One collaboration product

One technology stack

At the BeginningA Monolith in Every Aspect

@suksr#VoxxedMicroservices

Page 8: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

BackgroundAfter an Evolving Time

@suksr#VoxxedMicroservices

Page 9: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

BackgroundAfter an Evolving Time

Productivity suffered

@suksr#VoxxedMicroservices

Page 10: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

BackgroundAfter an Evolving Time

Productivity suffered

Usability/UX suffered

@suksr#VoxxedMicroservices

Page 11: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

BackgroundAfter an Evolving Time

Productivity suffered

Usability/UX suffered

New features released slowly

@suksr#VoxxedMicroservices

Page 12: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

JUST DRIVE JUST CONNECT JUST LIST JUST WIKI

JUST PEOPLE JUST NEWS

JUST SOCIAL

BackgroundSeparate Collaboration Apps

@suksr#VoxxedMicroservices

Page 13: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

BackgroundSeparate, Autonomous Teams

Well-defined responsibilites

@suksr#VoxxedMicroservices

Page 14: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

BackgroundIn The Long Run

Organisation Product Software

@suksr#VoxxedMicroservices

Page 15: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

BackgroundOur Motivation for Microservices

Autonomous teams

Develop independently Deploy independentlyWork at different partsindependently

Scale independently

At different speed

@suksr#VoxxedMicroservices

Page 16: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Identify Bounded ContextsDecomposition Strategy

High cohesion within a service

Loose coupling between services

@suksr#VoxxedMicroservices

Page 17: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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

@suksr#VoxxedMicroservices

Page 18: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Identify Bounded ContextsDecomposition Strategy

JUST DRIVE JUST CONNECT JUST LIST

JUST WIKIJUST PEOPLE JUST NEWS

Bounded Contexts

@suksr#VoxxedMicroservices

Page 19: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

JUST DRIVE

Decomposition StrategyCo-Existing Service From Scratch

@suksr#VoxxedMicroservices

Page 20: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

JUST DRIVE

Decomposition StrategyCo-Existing Service From Scratch

JUST PEOPLE

@suksr#VoxxedMicroservices

Page 21: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Decomposition StrategyCo-Existing Service From Scratch

owns documentstate

REST API

Application-Service

Domain-Model

DB AdapterMonolith

JUST DRIVE

@suksr#VoxxedMicroservices

Page 22: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Decomposition StrategyCo-Existing Service From Scratch

owns documentstate

owns profilestate

documentcreated by author

Monolith

REST API

Application-Service

Domain-Model

DB Adapter

@suksr#VoxxedMicroservices

Page 23: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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

@suksr#VoxxedMicroservices

Page 24: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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

@suksr#VoxxedMicroservices

Page 25: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Incremental Top Down

Extracting Web App

Decomposition Strategy

Monolith

REST API

REST API

REST Client

@suksr#VoxxedMicroservices

Page 26: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Monolith

REST API

Extracting Business Logic

Application-Service

Domain-Model

DB Adapter

REST Client

Incremental Top DownDecomposition Strategy

Monolith usesextracted business logic

@suksr#VoxxedMicroservices

Page 27: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Monolith

Splitting Data Storage

Incremental Top DownDecomposition Strategy

REST API

Application-Service

Domain-Model

DB Adapter

Events

Message Broker

Message BrokerAdapter

publishsubscribe

@suksr#VoxxedMicroservices

Page 28: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Which One First?

vs.

Easy to Extract

Changing Frequently

Different Resource ConsumptionEarly experiences w/ Microservices

Greatest benefit after extraction

Decomposition Strategy

@suksr#VoxxedMicroservices

Page 29: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Cross-Cutting ConcernsAuthorization

JUST DRIVE JUST WIKI

Fine-grained authorization

Inter-service dependency

@suksr#VoxxedMicroservices

Page 30: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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

@suksr#VoxxedMicroservices

Page 31: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Cross-Cutting ConcernsHandle Them Early

Feeding the monolith

Re-implementing authz w/ everynew service

Handle Cross-Cutting Concerns Early

@suksr#VoxxedMicroservices

Page 32: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Cross-Cutting ConcernsAvoid A Distributed Monolith

Authz Service

@suksr#VoxxedMicroservices

Page 33: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Cross-Cutting ConcernsAvoid A Distributed Monolith

Authz Servicetranslate

One stable common contract

translate

translate

@suksr#VoxxedMicroservices

Page 34: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Service InteractionRequest-Driven / Event-Driven

command

query EventsMessage Broker

publish subscribe

command

query

Request-Driven Hybrid

EventsMessage Broker

publish subscribe

Event-Driven

@suksr#VoxxedMicroservices

Page 35: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

How To Manage Shared Data?Hybrid Model

Message Broker

REST API

Remote query directly to source

Events for notification

@suksr#VoxxedMicroservices

Page 36: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Event Driven State Transfer

Message Broker

Local copy of profile data

ProfileUpdatedEvent

How To Manage Shared Data?

Events for data duplication

@suksr#VoxxedMicroservices

Page 37: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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

@suksr#VoxxedMicroservices

Page 38: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Messaging System Storage System Streaming Platform

Message Broker

Event Log Event Stream

@suksr#VoxxedMicroservices

Page 39: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

How To Manage Shared Data?Kafka Streams

Unbounded, ordered sequenceof data records

Key-value pairContinuouslyupdating

@suksr#VoxxedMicroservices

Page 40: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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

@suksr#VoxxedMicroservices

Page 41: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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→

@suksr#VoxxedMicroservices

Page 42: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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

@suksr#VoxxedMicroservices

Page 43: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

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@suksr#VoxxedMicroservices

Page 44: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Hardware Data Store

API API-Gateway Service Discovery Load-BalancerMessage Broker

Timeout-Handling Retries Idempotency Bulkheads Circuit Breaker

Config-Mngmt.Monitoring Log Aggreation Metrics Distributed

TracingHealth Checks

SCM

O/SVirtualization Container Runtime

Checkout TestBuild CI/CD Pipeline

Deploy

µService

Backup Recovery

@suksr#VoxxedMicroservices

Infrastructure Complexities

Page 45: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Build the things that differentiate you

Offload the things that don’t

@suksr#VoxxedMicroservices

Page 46: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Hardware

O/S

Virtualization

Container

Runtime

Managed Services

O/S

Orchestration

Data Store

µService

Offload by getting common building blocks managed by cloud providers

Page 47: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Start small

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

@suksr#VoxxedMicroservices

Consider managed services to offloadinfrastructure complexities

Page 48: Microservices Lessons Learned...Microservices Lessons Learned CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr #VoxxedMicroservices @suksr Each

Susanne KaiserIndependent Tech Consultant

@suksr

CTO at Just Software@JustSocialApps