31
Microservices – The 7 Deadly Sins Cork ALT.NET Feb 2016

The 7 deadly sins of micro services

Embed Size (px)

Citation preview

Page 1: The 7 deadly sins of micro services

Microservices – The 7 Deadly Sins

Cork ALT.NET Feb 2016

Page 2: The 7 deadly sins of micro services

Agenda• Overview• Benefits• The Seven Deadly Sins • Questions & Wrap Up

Page 3: The 7 deadly sins of micro services
Page 4: The 7 deadly sins of micro services

• Small autonomous services that work together• Focused on one business capability and doing it well• Deploy independently• Scale independently• No centralised, shared database

Page 5: The 7 deadly sins of micro services

Benefits• Optimized for change• More resilience • Forces you to deal with eventual consistency• Increased productivity - smaller teams on smaller codebases work faster

• Freedom to pick the right technology for each service

Page 6: The 7 deadly sins of micro services

Adopters• Netflix• eBay• Amazon• Gilt• REA• Twitter• PayPal• SoundCloud• Hailo• Uber• Google• Cloud Foundry and

many more…

Page 7: The 7 deadly sins of micro services

Portal PracticeApp

Third PartyApp

API Gateway

STS (OAuth) Contact (CRM) Provisioning User Mgt FeaturesToggles

Doc Storage

WorkflowTax Prep Notification

Tax LodgementBusiness Event Digital Signing

ConversationLedger

Desktop client

SyncService

Client Portal

LedgerAggregator

Stat Reporting Log Aggregator

Page 8: The 7 deadly sins of micro services

7 Deadly Sins..

Page 9: The 7 deadly sins of micro services

Lust MmmmMmm shiney!

Page 10: The 7 deadly sins of micro services

• Start small• You need a great DevOps culture to make Microservices work• Don't have too many variations between each tech stack• Get current stay current• Consider operations whenever you add new technology• Create a stencil project / service template – this should be

immediately deployable and kept up to date

Page 11: The 7 deadly sins of micro services

Gluttony MmmmMmm … free resources

Page 12: The 7 deadly sins of micro services

the circuit breaker…

Page 13: The 7 deadly sins of micro services

https://github.com/App-vNext/Polly

// break the circuit after the specified number of exceptions// and keep circuit broken for the specified duration

var policy = Policy .Handle<ServiceUnavailableException>() .CircuitBreaker(2, TimeSpan.FromMinutes(1));Policy.Execute((=>YourAPICall))

Page 14: The 7 deadly sins of micro services

Greed Need to make more..

Page 15: The 7 deadly sins of micro services

• A microservices that do little more than expose a CRUD style interface result in an anemic data models that won’t be reused

• Start bigger, when you feel that a section of one a services needs to be scaled independently from the rest of the functionality, that's a good indicator of a need to create a separate microservice.

• Appoint service owners / custodians for each service.

Page 16: The 7 deadly sins of micro services

Conway’s Law

“Organizations which design systems ... are constrained to

produce designs which are copies of the

communication structures of these organizations”

— M. Conway 1967

Page 17: The 7 deadly sins of micro services

I can’t do anything by myselfSloth

Page 18: The 7 deadly sins of micro services

• 1 service per repo • 1 pipeline per service• Build once, deploy many times• Version all API contracts• Service locator

Page 19: The 7 deadly sins of micro services

Wrath

Beware distributed system !Wrath

Page 20: The 7 deadly sins of micro services

• Know what “normal” looks like for each microservice and the overall system

• Information Radiators & Dashboards• Pass CorrelationIDs in all message headers• Use synthetic transactions in production• Realtime telemetry & dashboards• Alerts when auto scaling happens & synthetic transactions fail

Page 21: The 7 deadly sins of micro services
Page 22: The 7 deadly sins of micro services

EnvyI’ll be deploying to

production in 2 weeks time

Page 23: The 7 deadly sins of micro services

• Embrace continuous delivery as an organisation• Doing something all the time takes the pain out of it & makes you

good at it• Feature Switch everything• Rethinking configuration – prefer convention over configuration• Immutable Infrastructure• Releasing a feature and turning it on are 2 separate things• Every code change is backward compatible• Blue Green Deployments

Page 24: The 7 deadly sins of micro services

Blue-Green Deployment

Page 25: The 7 deadly sins of micro services

PrideI don’t write buggy code, no need for automated tests !

Page 26: The 7 deadly sins of micro services

Unit

Service

UI

Faster, more isolated

Increased scope and slower

Page 27: The 7 deadly sins of micro services

Pact – Consumer Driven Contract Test

Page 28: The 7 deadly sins of micro services

• It forces a conversation between the consumer and the provider • Pact tests are easy to run standalone as part of a CI build pipeline or

on anyone's dev machine• Best part is you end up with a standalone CI pipeline for each service

but within this pipeline we get to verify all expectations of the consumers of the service !

• Gives consumers a safety net - their tests are continually run as part of the API providers CI pipeline

• Pact broker - gives a picture of all the API consumers & the API call graphs

Page 29: The 7 deadly sins of micro services

E2E User Journey Tests• pick a handful of key workflows across your application ( less than 10)• Brittle and expensive to maintain so choose wisely• Never let them break• Don’t be afraid to throw them away and create new ones over time

Page 30: The 7 deadly sins of micro services

Summary

• Lust –chasing shiney new technology & tools• Gluttony - no circuit breakers to prevent cascading failures• Greed – creating too many services with the wrong bounded contexts• Sloth – creating a distributed monolith• Wrath – ignoring the wrath of distributed systems• Envy – your build and deploy process must be a joy to behold • Pride – fooled into thinking you don’t need proper tests

Page 31: The 7 deadly sins of micro services

Recommended Reading