microservices 5 things i wish i'd known

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

Upload: vincent-kok

Post on 14-Jan-2017

141 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Microservices 5 things i wish i'd known

VINCENT KOK • DEV MANAGER • ATLASSIAN • @VINCENTKOK

Microservices5 things I wish I’d known

Page 2: Microservices 5 things i wish i'd known

B U I L D I N G M I C R O S E RV I C E S

I S S U E S

M O V I N G F O RWA R D

Agenda

Page 3: Microservices 5 things i wish i'd known

• 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

• 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

• 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

• 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 promise of Microservices

Small Independent lifecycle ReplaceableRight tool

Page 8: Microservices 5 things i wish i'd known

• 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

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

https://flic.kr/p/kENTD4

Fast forward to the top

Page 10: Microservices 5 things i wish i'd known

• 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

Examples

Page 12: Microservices 5 things i wish i'd known

Confluence

Connect

Conversion

Filestore

Page 13: Microservices 5 things i wish i'd known

Identity

6+AvatarLogin

Page 14: Microservices 5 things i wish i'd known

Build

Page 15: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Build a pattern

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

Page 16: Microservices 5 things i wish i'd known

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

Anatomy of a service

Page 18: Microservices 5 things i wish i'd known

Health check

200!200

Page 19: Microservices 5 things i wish i'd known

/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

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

Page 21: Microservices 5 things i wish i'd known

1 Build1 Repository

For every service

Page 22: Microservices 5 things i wish i'd known

One Bitbucket repository per service

Page 23: Microservices 5 things i wish i'd known

From slow

MTTR

Page 24: Microservices 5 things i wish i'd known

To fast and reliable

A slightly better MTTR

Page 25: Microservices 5 things i wish i'd known

Configure

Page 26: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

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

Prevent different lifecycles

Page 27: Microservices 5 things i wish i'd known

Layered layout

Common configuration per environment

Per serviceCommon configuration per service

Per environment

Page 28: Microservices 5 things i wish i'd known

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 29: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

No secrets

Page 30: Microservices 5 things i wish i'd known

Deploy

Page 31: Microservices 5 things i wish i'd known

DeployBuild and testCommit to master

Deployment pipeline

Release

Page 32: Microservices 5 things i wish i'd known

Environments

Development Staging Production Disaster Recovery

Page 33: Microservices 5 things i wish i'd known

Build and upload

Deployment projects take

care of the actual deployment

Page 34: Microservices 5 things i wish i'd known

Create release from build

Build release information

Page 35: Microservices 5 things i wish i'd known

Feedback per environment

Versioned release per environment

Page 36: Microservices 5 things i wish i'd known

Test

Page 37: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Isolation

https://flic.kr/p/dxUhia

Page 38: Microservices 5 things i wish i'd known

PDVFunctional testsUnit tests

Test strategy

Contract tests

Page 39: Microservices 5 things i wish i'd known

Functional tests

Stub Service mock

Page 40: Microservices 5 things i wish i'd known

Stub sample

<beans profile="it">

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

Page 41: Microservices 5 things i wish i'd known

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

Page 42: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Consumer Driven Contract Testing

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

Page 43: Microservices 5 things i wish i'd known

An example

Service A Service B

REST

Consumer Provider

Page 44: Microservices 5 things i wish i'd known

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 45: Microservices 5 things i wish i'd known

Consumer side

HTTP request

HTTP responseClient Service Mock PACT

Page 46: Microservices 5 things i wish i'd known

Provider side

HTTP request

HTTP responsePACT PACT runner Provider

Page 47: Microservices 5 things i wish i'd known

PACT Matrix

Consumer master Consumer prod

Provider master Latest compatibleProvider

Compatible

Provider prod Consumer Compatible Already tested

Page 48: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Post Deployment Verification

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

Page 49: Microservices 5 things i wish i'd known

PDV

Development Staging Production Disaster Recovery

Page 50: Microservices 5 things i wish i'd known

Operate

Page 51: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

100 lbs

https://flic.kr/p/biy2an

99% of water

dehydrate to 98%

How much do they weigh now?

Page 52: Microservices 5 things i wish i'd known

50lbs

Page 53: Microservices 5 things i wish i'd known

• 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 54: Microservices 5 things i wish i'd known

99.99 = 99.7%30

Page 55: Microservices 5 things i wish i'd known

4m23 to

> 2h

Page 56: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Know your system!

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

Page 57: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Page 58: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Page 59: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Page 60: Microservices 5 things i wish i'd known

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 61: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Page 62: Microservices 5 things i wish i'd known

Moving forward

Page 63: Microservices 5 things i wish i'd known

5 Things

Page 64: Microservices 5 things i wish i'd known

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

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

More decisions to come

Page 65: Microservices 5 things i wish i'd known

Thank you!

VINCENT KOK • DEV MANAGER • ATLASSIAN • @VINCENTKOK