Microservices Lessons Learned Susanne Kaiser Independent Tech - - PowerPoint PPT Presentation

microservices lessons learned
SMART_READER_LITE
LIVE PREVIEW

Microservices Lessons Learned Susanne Kaiser Independent Tech - - PowerPoint PPT Presentation

Microservices Lessons Learned Susanne Kaiser Independent Tech Consultant @suksr CTO at Just Software @JustSocialApps #VoxxedMicroservices @suksr Each Journey is Different People try to copy Netflix, but they can only copy what they see.


slide-1
SLIDE 1

Microservices Lessons Learned

CTO at Just Software @JustSocialApps Susanne Kaiser Independent Tech Consultant @suksr

@suksr #VoxxedMicroservices

slide-2
SLIDE 2

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

slide-3
SLIDE 3

Each Journey is Different

Team

Structure Skillset Size

Journey

Affecting Circumstances

@suksr #VoxxedMicroservices

slide-4
SLIDE 4

Each Journey is Different

Team

Structure Skillset Size

Journey Legacy

Maintenance effort Runtime environment

Affecting Circumstances

@suksr #VoxxedMicroservices

slide-5
SLIDE 5

Each Journey is Different

Team

Structure Skillset Size

Journey Legacy

Maintenance effort Runtime environment

Strategy

New Features Timeline / Milestones

Affecting Circumstances

@suksr #VoxxedMicroservices

slide-6
SLIDE 6

Background

JUST DRIVE JUST CONNECT JUST LIST JUST WIKI JUST PEOPLE JUST NEWS JUST SOCIAL @suksr #VoxxedMicroservices

slide-7
SLIDE 7

One team Single Unit One collaboration product One technology stack

At the Beginning

A Monolith in Every Aspect

@suksr #VoxxedMicroservices

slide-8
SLIDE 8

Background

After an Evolving Time

@suksr #VoxxedMicroservices

slide-9
SLIDE 9

Background

After an Evolving Time

Productivity suffered

@suksr #VoxxedMicroservices

slide-10
SLIDE 10

Background

After an Evolving Time

Productivity suffered Usability/UX suffered

@suksr #VoxxedMicroservices

slide-11
SLIDE 11

Background

After an Evolving Time

Productivity suffered Usability/UX suffered New features released slowly

@suksr #VoxxedMicroservices

slide-12
SLIDE 12

JUST DRIVE JUST CONNECT JUST LIST JUST WIKI JUST PEOPLE JUST NEWS JUST SOCIAL

Background

Separate Collaboration Apps

@suksr #VoxxedMicroservices

slide-13
SLIDE 13

Background

Separate, Autonomous Teams

Well-defined responsibilites @suksr #VoxxedMicroservices

slide-14
SLIDE 14

Background

In The Long Run

Organisation Product Software

@suksr #VoxxedMicroservices

slide-15
SLIDE 15

Background

Our Motivation for Microservices

Autonomous teams Develop independently Deploy independently Work at different parts independently Scale independently At different speed @suksr #VoxxedMicroservices

slide-16
SLIDE 16

Identify Bounded Contexts

Decomposition Strategy

High cohesion within a service Loose coupling between services @suksr #VoxxedMicroservices

slide-17
SLIDE 17

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

slide-18
SLIDE 18

Identify Bounded Contexts

Decomposition Strategy

JUST DRIVE JUST CONNECT JUST LIST JUST WIKI JUST PEOPLE JUST NEWS

Bounded Contexts

@suksr #VoxxedMicroservices

slide-19
SLIDE 19

JUST DRIVE

Decomposition Strategy

Co-Existing Service From Scratch

@suksr #VoxxedMicroservices

slide-20
SLIDE 20

JUST DRIVE

Decomposition Strategy

Co-Existing Service From Scratch

JUST PEOPLE @suksr #VoxxedMicroservices

slide-21
SLIDE 21

Decomposition Strategy

Co-Existing Service From Scratch

  • wns document

state

REST API Application-Service Domain-Model DB Adapter Monolith

JUST DRIVE @suksr #VoxxedMicroservices

slide-22
SLIDE 22

Decomposition Strategy

Co-Existing Service From Scratch

  • wns document

state

  • wns profile

state document created by author

Monolith REST API Application-Service Domain-Model DB Adapter

@suksr #VoxxedMicroservices

slide-23
SLIDE 23
  • wns document

state

  • wns profile

state

Events

local copy

  • f author

Message Broker

Decomposition Strategy

Co-Existing Service From Scratch

REST API Application-Service Domain-Model DB Adapter Message Broker Adapter Monolith publish subscribe

@suksr #VoxxedMicroservices

slide-24
SLIDE 24

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

@suksr #VoxxedMicroservices

slide-25
SLIDE 25

Incremental Top Down Extracting Web App

Decomposition Strategy

Monolith REST API REST API REST Client

@suksr #VoxxedMicroservices

slide-26
SLIDE 26

Monolith REST API

Extracting Business Logic

Application-Service Domain-Model DB Adapter REST Client

Incremental Top Down

Decomposition Strategy

Monolith uses extracted business logic @suksr #VoxxedMicroservices

slide-27
SLIDE 27

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

@suksr #VoxxedMicroservices

slide-28
SLIDE 28

Which One First?

vs.

Easy to Extract Changing Frequently Different Resource Consumption Early experiences w/ Microservices Greatest benefit after extraction

Decomposition Strategy

@suksr #VoxxedMicroservices

slide-29
SLIDE 29

Cross-Cutting Concerns

Authorization

JUST DRIVE JUST WIKI Fine-grained authorization Inter-service dependency @suksr #VoxxedMicroservices

slide-30
SLIDE 30

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

@suksr #VoxxedMicroservices

slide-31
SLIDE 31

Cross-Cutting Concerns

Handle Them Early

Feeding the monolith Re-implementing authz w/ every new service

Handle Cross-Cutting Concerns Early

@suksr #VoxxedMicroservices

slide-32
SLIDE 32

Cross-Cutting Concerns

Avoid A Distributed Monolith

Authz Service @suksr #VoxxedMicroservices

slide-33
SLIDE 33

Cross-Cutting Concerns

Avoid A Distributed Monolith

Authz Service

translate

One stable common contract

translate translate

@suksr #VoxxedMicroservices

slide-34
SLIDE 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

@suksr #VoxxedMicroservices

slide-35
SLIDE 35

How To Manage Shared Data?

Hybrid Model

Message Broker

REST API

Remote query directly to source Events for notification @suksr #VoxxedMicroservices

slide-36
SLIDE 36

Event Driven State Transfer

Message Broker

Local copy of profile data ProfileUpdatedEvent

How To Manage Shared Data?

Events for data duplication @suksr #VoxxedMicroservices

slide-37
SLIDE 37

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

slide-38
SLIDE 38

Messaging System Storage System Streaming Platform

Message Broker Event Log Event Stream @suksr #VoxxedMicroservices

slide-39
SLIDE 39

How To Manage Shared Data?

Kafka Streams

Unbounded, ordered sequence

  • f data records

Key-value pair Continuously updating

@suksr #VoxxedMicroservices

slide-40
SLIDE 40

How To Manage Shared Data?

Kafka Streams

Kafka Topic Lightweight embedded state store (disk-backed) Service Running in the same process

  • f Microservice

Loaded on startup of Microservice

Streams make data available wherever it’s needed

@suksr #VoxxedMicroservices

slide-41
SLIDE 41

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 →

@suksr #VoxxedMicroservices

slide-42
SLIDE 42

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

slide-43
SLIDE 43

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

slide-44
SLIDE 44

Hardware Data Store API API-Gateway Service Discovery Load-Balancer Message Broker Timeout-Handling Retries Idempotency Bulkheads Circuit Breaker Config-Mngmt. Monitoring Log Aggreation Metrics Distributed Tracing Health Checks SCM O/S Virtualization Container Runtime

Checkout Test Build

CI/CD Pipeline

Deploy

µService Backup Recovery

@suksr #VoxxedMicroservices

Infrastructure Complexities

slide-45
SLIDE 45

Build the things that differentiate you Offload the things that don’t

@suksr #VoxxedMicroservices

slide-46
SLIDE 46

Hardware O/S Virtualization Container Runtime

Managed Services

O/S Orchestration Data Store µService

Offload by getting common building blocks managed by cloud providers

slide-47
SLIDE 47

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 offload infrastructure complexities

slide-48
SLIDE 48

Susanne Kaiser Independent Tech Consultant @suksr CTO at Just Software @JustSocialApps