Upload
pivotal
View
294
Download
1
Embed Size (px)
Citation preview
Microservices In a Legacy Environment
Principles & Examples
David Julia
@DavidJulia [email protected] Associate Director
In a Microservices Architecture
Services are cheap and fast to deploy and change independently.
Spring BootSimple and cheap to spin up a new microservice!
Autoconfiguration for standard boilerplate config
Legacy Environment: An environment wherein many systems that are hard to change are in dire need of replacement or augmentation to meet business demands.
This talk is for Developers. I want to show you how to get to microservices when you’re starting with a Big Ball of Mud.
The Importance of DDD in Legacy Environments
Don’t couple your domain model to your legacy systems’ models
Represent the latest business processes in code
Appcontinuum.io (thanks Mike Barinek)!
Evolving Components & Services
How do I break them out safely?
Succession /səәkˈseSHəәn/ Noun
The art of taking a single conceptual change, breaking it into safe steps, and then finding an order for those steps that optimizes safety, feedback, and efficiency
Succession Patterns let’s talk about a few
Strangler Application Pattern
Gradually create a new system around the edges of the old, letting it grow slowly over several years until the old system is
strangled
Characterization tests - a vice
An example:
Large fast food restaurant chain writing a mobile app
Replace rewards points vendor with their own system
Cut cost
Show reward points on iOS app
Set ourselves up to add new features
Motivation
First, let’s tackle viewing current rewards point
balance on iOS
Let’s look at our systems!
Let’s look at part of our Ball of Mud POS!
What’s the plan?
● Identify behavior we need.
● “Sprout” a new class to hold the behavior we want
● Start moving behavior into that class
● Extract a component (JAR) and break dependencies
Could stop here and use the library in our mobile API gateway. Or continue on and extract a service.
Sprout Method & Sprout Class
Sprouting = extracting new behavior
to a new method or class.
Can then add tests/new behavior
And now sprout component (jar)
But is it safe? i.e. “Does it match the website’s balance?”
Remember that web interface? it’s a test oracle!…Record any Δ’s
as bugs, and fix them.
We’re liking what we’re seeing… No Δ’s
“That diff thing won’t work for me!”
“I have mutating operations (edits/deletes)!”Same basic strategy, one modification:Noop in your new service implementationLog what you “would have done”
This is just one example of succession. Creativity is often required :)
*level of caution can be adjusted to your risk profile
Now Let’s extract a service!
But first… A note on premature extraction
Extracting a service too early can be costly
It’s easier to refactor the system with an in-process component
Easier to change your abstractions (interface changes)
Only have to change things in one place
Extract a service!
Let’s say we want a separate service**
● Extract a service, implement a remote façade at the seam we created
● Point iOS application API Gateway at the service
● Celebrate!
**for more info on when to extract a microservice vs stay with shared libraries, see Mike Gehard’s talk
Finally, add a mobile API Gateway
and iOS app!
What did we just see
Started with a ball of mud
Identified/Extracted behavior into new classes
Packaged classes as JAR
Created a new service (strangler application)
Did all of this safely and with high confidence
Next Steps
• Continue to move rewards-specific behavior to our service
• Could refactor the web GUI to use our new service
Thanks! ...Questions?
Appendix/Links
Mike Barinek’s appcontinuum.io
Simon Brown on Modular Monoliths http://www.codingthearchitecture.com/presentations/sa2015-modular-monoliths
Mike Gehard on Microservices https://vimeo.com/album/4045988/video/172421431
Working Effectively With Legacy Code by Michael Feathers