Microservices are awesome, when they're done right. Teams start with microservices with the best intentions and sometimes end up hurting themselves and the business in doing so. There are many gotchas and oversights that could make the experience a bit painful or in some cases a complete disaster. In this presentation I talk about some of the happy and not so happy lessons I've learnt in implementing microservices over the years.
68. Werner Vogels:
"No direct database access is
allowed from outside the service,
and there’s no data sharing
among the services."
http://queue.acm.org/detail.cfm?id=1142065
111. “We need to stop obsessing
about quality and focus on
getting this out soon.”
112. Conway’s Law:
“Organizations which design
systems are constrained to produce
systems which are copies of the
communication structures of these
organizations.”
We see something awesome and we get really excited about it and think I want to be like that. I want to do that
One repo
One programming language
One database
One deployment
One repo
One programming language
One database
One deployment
One repo
One programming language
One database
One deployment
One repo
One programming language
One database
One deployment
One repo
One programming language
One database
One deployment
Each service has
One repo
One programming language
One data store
And one deployment
Each service has
One repo
One programming language
One data store
And one deployment
Each service has
One repo
One programming language
One data store
And one deployment
Each service has
One repo
One programming language
One data store
And one deployment
Each service has
One repo
One programming language
One data store
And one deployment
Each service has
One repo
One programming language
One data store
And one deployment
Scale the bits that require scale.
Encapsulate data with the services
No locks => Scalability
Ease of maintenance: 4000 sps and 1000 tables!
allows services and consumers to evolve independently of each other.
reimplement a service as long as from outside it looks and behaves the same
It's not all or nothing unlike monolith
Monolith is one repo
not as many merge conflicts
not as much consistency force/requirement
Less code => easier to understand => faster to run => easier to maintain
Eliminates any long-term commitment to a technology stack.
Use right tool, standards and stack for every service and change it whenever you like.
from scoping out the functionality, to architecting it, to building it, and operating it
Each service can be deployed independently of other services - easier to deploy new versions of services frequently.
Less to release each time => CD => all the benefits of CD
Smaller services are easier to change and evolve and that facilitates experimentation
Create a new microservice to experiment with an idea in isolation of the rest of the system. If it flies, keep it. If it doesn't, kill it.
This actually shows one of the bigger risks with microservices: when it hurts, it really hurts!!
Akamai NetStorage
Assume everything your system talks to is broken and write it so it can cope!
when one of your dependencies stops responding, you need to stop calling it for a little while.
circuit breaker
Fire & forget
Pub/sub
Contain the failure
Hitting a different URL
Caching
Returning a canned response (null)
circuit breaker with fallbacks and graceful degradation
monitoring
Guaranteed fire & forget
background processing
Don't wait for it to fail before you fix it
to expose the error count, response times, up time, transaction per second
simulate an action or path that a customer or end-user would take.
continuously monitor
functionality, availability, and response time measures
Helps with troubleshooting and also with health monitoring
We were getting exception on an endpoint because it was missing a param
Where did the traffic came in from?
you’ll lose most of microservices benefits
We changed a stored procedure’s param and it broke BI
In a monolithic app you have transactions
You will have slower transactions, and might create system wide locking!
We were introducing soft deletes and we didn’t know what would be impacted
Pact: DSL, generates mock and plays back the request for the provider
Consumer codes against a mock and provider complies with contracts
Unit testing
so when you want to change the behavior of something you know what will be impacted
Extensive logging
Correlation id
Transaction code
Log aggregation
Extensive logging
Correlation id
Transaction code
Log aggregation
It will be resisted by operations and change management
Resistance by ops
And you should have a bounded context representing each capability
keep to your bounded context
A business person should be able to look at a high level map of the architecture and see the business represented there and similarly as technologists we should be able to look at the business and see the architecture represented there.
The microservices culture
Explain what’s wrong with this
Not organizations doing agile; but agile organization
Micro management
Long release process
Hard to sell unit testing