microservices 5 things i wish i'd known - the meetup edition

62
VINCENT KOK DEV MANAGER ATLASSIAN @VINCENTKOK Microservices 5 things I wish I’d known

Upload: vincent-kok

Post on 14-Jan-2017

344 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Microservices 5 things i wish i'd known - The MeetUp edition

VINCENT KOK • DEV MANAGER • ATLASSIAN • @VINCENTKOK

Microservices5 things I wish I’d known

Page 2: Microservices 5 things i wish i'd known - The MeetUp edition

5 T H I N G S

T H E P R O M I S E

M O R E T H I N G S

Agenda

R E A L L I F E E X A M P L E S

Page 3: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/fSopv4

You’ve got issues

Page 4: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/7WcQwA

Slow down

Page 5: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/bRgBZP

Lock up

Page 6: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/bByin8

Technology will age

Page 7: Microservices 5 things i wish i'd known - The MeetUp edition

The promise of Microservices

Small Independent lifecycle ReplaceableRight tool

Page 8: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/aSqP7p

Steep journey ahead

Page 9: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/kENTD4

5 lessons learned

Page 10: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/kENTD4

http://images.clipartpanda.com/rainbow-unicorn-cute-tumblr_lj9cy4iZ821qdabzno1_r4_500.png

No silver bullet

Page 11: Microservices 5 things i wish i'd known - The MeetUp edition

Real life examples

Page 12: Microservices 5 things i wish i'd known - The MeetUp edition

Confluence

Connect

Conversion

Filestore

Page 13: Microservices 5 things i wish i'd known - The MeetUp edition

Identity

6+AvatarLogin

Page 14: Microservices 5 things i wish i'd known - The MeetUp edition

5 Things

Page 15: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

#1: Build a pattern

https://flic.kr/p/8ykpkW

Page 16: Microservices 5 things i wish i'd known - The MeetUp edition

The Twelve Factor App

XI. Logs

One codebase tracked in revision control, many deploys

V. Build, release, runStrictly separate build and run stages

I. Codebase

Treat logs as event streams

Page 17: Microservices 5 things i wish i'd known - The MeetUp edition

Anatomy of a service

Page 18: Microservices 5 things i wish i'd known - The MeetUp edition

Health check

200!200

Page 19: Microservices 5 things i wish i'd known - The MeetUp edition

/healthcheck

{ "avatar": { "details": {}, "isHealthy": true, "metadata": { "hash": "379965ce", "name": "Avatar service", "version": "2.0.8" } }}

Page 20: Microservices 5 things i wish i'd known - The MeetUp edition

/healthcheck/details{ "avatar": { "details": { "avatarRepository": { "isHealthy": true }, "crowd": { "isHealthy": true }, "deadlock": { "isHealthy": true

Page 21: Microservices 5 things i wish i'd known - The MeetUp edition

1 Build1 Repository

For every service

Page 22: Microservices 5 things i wish i'd known - The MeetUp edition

From slow

MTTR

Page 23: Microservices 5 things i wish i'd known - The MeetUp edition

To fast and reliable

A slightly better MTTR

Page 24: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/8prXA6

#2: Prevent different lifecycles

Page 25: Microservices 5 things i wish i'd known - The MeetUp edition

Layered layout

Common configuration per environment

Per serviceCommon configuration per service

Per environment

Page 26: Microservices 5 things i wish i'd known - The MeetUp edition

Simple formatinclude "common.prod.conf"include "service.conf"

http { port = 8080 interface = "127.0.0.1"}

recaptcha.key.site = "....."recaptcha.enable = true

static.asset.base = "...."

Page 27: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

No secrets

Page 28: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

#3: Deploying should dead simple

https://flic.kr/p/qP31Tf

Page 29: Microservices 5 things i wish i'd known - The MeetUp edition

DeployBuild and testCommit to master

Deployment pipeline

Release

Page 30: Microservices 5 things i wish i'd known - The MeetUp edition

Environments

Development Staging Production Disaster Recovery

Page 31: Microservices 5 things i wish i'd known - The MeetUp edition

Build and upload

Deployment projects take

care of the actual deployment

Page 32: Microservices 5 things i wish i'd known - The MeetUp edition

Create release from build

Build release information

Page 33: Microservices 5 things i wish i'd known - The MeetUp edition

Declarative deploymentname: My Serviceorganization: "My:Org"description: Yet Another Microservicelinks: binary: type: maven artifactId: saml version: 0.0.1 classifier: assembly healthcheck: uri: healthcheck source: url: "https://www.bitbucket.org/myservice"externalAccess: falsenotifications: email: "[email protected]"scaling: min: 4 max: 8

Page 34: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

#4: Test in isolation

https://flic.kr/p/dxUhia

Page 35: Microservices 5 things i wish i'd known - The MeetUp edition

PDVFunctional testsUnit tests

Test strategy

Contract tests

Page 36: Microservices 5 things i wish i'd known - The MeetUp edition

Functional tests

Stub Service mock

Page 37: Microservices 5 things i wish i'd known - The MeetUp edition

Stub sample

<beans profile="it">

<bean id="myClient" class=“com.mycompany.MyStub”/> </beans>

Page 38: Microservices 5 things i wish i'd known - The MeetUp edition

WireMock sample{ "request": { "url": “/myresource", "method": “POST” "Accept": { "matches": “application/json” } }, "response": { "status": 204 }}

Page 39: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Consumer Driven Contract Testing

https://flic.kr/p/9mjRKW

Page 40: Microservices 5 things i wish i'd known - The MeetUp edition

An example

Service A Service B

REST

Consumer Provider

Page 41: Microservices 5 things i wish i'd known - The MeetUp edition

Consumer side

HTTP request

HTTP response

Client Service Mock PACT

Page 42: Microservices 5 things i wish i'd known - The MeetUp edition

Consumer expectation

uponReceiving("A request by user id for a user") .matching(path = "/Users/1") .willRespondWith(body = userByIdResponse) .during { providerConfig => Client(providerConfig.url).get("/Users/1)

must beEqualTo(200, Some(userByIdResponse)) }

Page 43: Microservices 5 things i wish i'd known - The MeetUp edition

Provider side

HTTP request

HTTP responsePACT PACT runner Provider

Page 44: Microservices 5 things i wish i'd known - The MeetUp edition

PACT Matrix

Consumer master Consumer prod

Provider master Latest compatibleProvider

Compatible

Provider prod Consumer Compatible Already tested

Page 45: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Post Deployment Verification

https://flic.kr/p/6wHFj5

Page 46: Microservices 5 things i wish i'd known - The MeetUp edition

PDV

Development Staging Production Disaster Recovery

Page 47: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

#5: Maximum visibility

Page 48: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

100 kg

https://flic.kr/p/biy2an

99% of water

dehydrate to 98%

How much do they weigh now?

Page 49: Microservices 5 things i wish i'd known - The MeetUp edition

50 kg

Page 50: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

What is the uptime of service that depends on 30 services

with an uptime of 99.99?

https://flic.kr/p/51TYD1

Page 51: Microservices 5 things i wish i'd known - The MeetUp edition

99.99 = 99.7%30

Page 52: Microservices 5 things i wish i'd known - The MeetUp edition

4m23 to

> 2h

Page 53: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Know your system!

https://flic.kr/p/9b24xc

Page 54: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Who thinks this is cool?

Page 55: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Page 56: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Page 57: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Page 58: Microservices 5 things i wish i'd known - The MeetUp edition

Trace your requests

X-B3-TraceId : 1X-B3-SpanId : 1

X-B3-TraceId : 1X-B3-SpanId : 2X-B3-ParentSpanId : 1

X-B3-TraceId : 1X-B3-SpanId : 3X-B3-ParentSpanId : 2

X-B3-TraceId : 1X-B3-SpanId : 4X-B3-ParentSpanId : 3

Page 59: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Page 60: Microservices 5 things i wish i'd known - The MeetUp edition

More things

Page 61: Microservices 5 things i wish i'd known - The MeetUp edition

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/3Esx3o

Technology stack Deployment platform

Yield and Harvest

Circuit brakers

Design for failure

Service Discovery

Team composition There is even more…

Page 62: Microservices 5 things i wish i'd known - The MeetUp edition

Thank you!

VINCENT KOK • DEV MANAGER • ATLASSIAN • @VINCENTKOK