Bootiful Microservices in a Legacy Environment: Lessons Learned
-
Upload
pivotal -
Category
Technology
-
view
294 -
download
1
Transcript of Bootiful Microservices in a Legacy Environment: Lessons Learned
![Page 1: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/1.jpg)
Microservices In a Legacy Environment
Principles & Examples
![Page 3: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/3.jpg)
In a Microservices Architecture
Services are cheap and fast to deploy and change independently.
![Page 4: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/4.jpg)
Spring BootSimple and cheap to spin up a new microservice!
Autoconfiguration for standard boilerplate config
![Page 5: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/5.jpg)
Legacy Environment: An environment wherein many systems that are hard to change are in dire need of replacement or augmentation to meet business demands.
![Page 6: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/6.jpg)
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.
![Page 7: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/7.jpg)
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
![Page 8: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/8.jpg)
Appcontinuum.io (thanks Mike Barinek)!
Evolving Components & Services
![Page 9: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/9.jpg)
How do I break them out safely?
![Page 10: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/10.jpg)
![Page 11: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/11.jpg)
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
![Page 12: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/12.jpg)
Succession Patterns let’s talk about a few
![Page 13: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/13.jpg)
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
![Page 14: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/14.jpg)
Characterization tests - a vice
![Page 15: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/15.jpg)
An example:
Large fast food restaurant chain writing a mobile app
Replace rewards points vendor with their own system
![Page 16: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/16.jpg)
Cut cost
Show reward points on iOS app
Set ourselves up to add new features
Motivation
![Page 17: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/17.jpg)
First, let’s tackle viewing current rewards point
balance on iOS
![Page 18: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/18.jpg)
Let’s look at our systems!
![Page 19: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/19.jpg)
![Page 20: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/20.jpg)
Let’s look at part of our Ball of Mud POS!
![Page 21: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/21.jpg)
![Page 22: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/22.jpg)
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.
![Page 23: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/23.jpg)
Sprout Method & Sprout Class
Sprouting = extracting new behavior
to a new method or class.
Can then add tests/new behavior
![Page 24: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/24.jpg)
![Page 25: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/25.jpg)
And now sprout component (jar)
![Page 26: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/26.jpg)
![Page 27: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/27.jpg)
![Page 28: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/28.jpg)
But is it safe? i.e. “Does it match the website’s balance?”
![Page 29: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/29.jpg)
Remember that web interface? it’s a test oracle!…Record any Δ’s
as bugs, and fix them.
![Page 30: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/30.jpg)
![Page 31: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/31.jpg)
![Page 32: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/32.jpg)
We’re liking what we’re seeing… No Δ’s
![Page 33: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/33.jpg)
“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
![Page 34: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/34.jpg)
Now Let’s extract a service!
![Page 35: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/35.jpg)
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
![Page 36: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/36.jpg)
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
![Page 37: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/37.jpg)
![Page 38: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/38.jpg)
Finally, add a mobile API Gateway
and iOS app!
![Page 39: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/39.jpg)
![Page 40: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/40.jpg)
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
![Page 41: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/41.jpg)
Next Steps
• Continue to move rewards-specific behavior to our service
• Could refactor the web GUI to use our new service
![Page 42: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/42.jpg)
Thanks! ...Questions?
![Page 43: Bootiful Microservices in a Legacy Environment: Lessons Learned](https://reader033.fdocuments.us/reader033/viewer/2022042707/58f1626c1a28ab0f2a8b456d/html5/thumbnails/43.jpg)
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