VINCENT KOK • DEV MANAGER • ATLASSIAN • @VINCENTKOK
Microservices5 things I wish I’d known
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
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
https://flic.kr/p/fSopv4
You’ve got issues
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
https://flic.kr/p/7WcQwA
Slow down
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
https://flic.kr/p/bRgBZP
Lock up
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
https://flic.kr/p/bByin8
Technology will age
The promise of Microservices
Small Independent lifecycle ReplaceableRight tool
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
https://flic.kr/p/aSqP7p
Steep journey ahead
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
https://flic.kr/p/kENTD4
5 lessons learned
• 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
Real life examples
Confluence
Connect
Conversion
Filestore
Identity
6+AvatarLogin
5 Things
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
#1: Build a pattern
https://flic.kr/p/8ykpkW
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
Anatomy of a service
Health check
200!200
/healthcheck
{ "avatar": { "details": {}, "isHealthy": true, "metadata": { "hash": "379965ce", "name": "Avatar service", "version": "2.0.8" } }}
/healthcheck/details{ "avatar": { "details": { "avatarRepository": { "isHealthy": true }, "crowd": { "isHealthy": true }, "deadlock": { "isHealthy": true
1 Build1 Repository
For every service
From slow
MTTR
To fast and reliable
A slightly better MTTR
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
https://flic.kr/p/8prXA6
#2: Prevent different lifecycles
Layered layout
Common configuration per environment
Per serviceCommon configuration per service
Per environment
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 = "...."
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
No secrets
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
#3: Deploying should dead simple
https://flic.kr/p/qP31Tf
DeployBuild and testCommit to master
Deployment pipeline
Release
Environments
Development Staging Production Disaster Recovery
Build and upload
Deployment projects take
care of the actual deployment
Create release from build
Build release information
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
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
#4: Test in isolation
https://flic.kr/p/dxUhia
PDVFunctional testsUnit tests
Test strategy
Contract tests
Functional tests
Stub Service mock
Stub sample
<beans profile="it">
<bean id="myClient" class=“com.mycompany.MyStub”/> </beans>
WireMock sample{ "request": { "url": “/myresource", "method": “POST” "Accept": { "matches": “application/json” } }, "response": { "status": 204 }}
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
Consumer Driven Contract Testing
https://flic.kr/p/9mjRKW
An example
Service A Service B
REST
Consumer Provider
Consumer side
HTTP request
HTTP response
Client Service Mock PACT
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)) }
Provider side
HTTP request
HTTP responsePACT PACT runner Provider
PACT Matrix
Consumer master Consumer prod
Provider master Latest compatibleProvider
Compatible
Provider prod Consumer Compatible Already tested
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
Post Deployment Verification
https://flic.kr/p/6wHFj5
PDV
Development Staging Production Disaster Recovery
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
#5: Maximum visibility
• 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?
50 kg
• 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
99.99 = 99.7%30
4m23 to
> 2h
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
Know your system!
https://flic.kr/p/9b24xc
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
Who thinks this is cool?
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
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
• Big cool statistic
• 2,569
• Add-Ons in Marketplace
More things
• 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…
Thank you!
VINCENT KOK • DEV MANAGER • ATLASSIAN • @VINCENTKOK
Top Related