Are microservices a wonder-pattern for rescuing intractably complex applications? Or are they just a restatement of the software engineering best practices we all should be following anyway? Or something in between?
How do they work? How should they be written? What are the pitfalls? What are the underpinning technologies?
Accompanying article: https://jaxenter.com/microservices-storm-in-a-teacup-or-teacups-in-a-storm-120388.html
5. Microservices. The best
thing since sliced bread.
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
Microservices: Good
design built-in!
Every microservice
comes with a free puppy.
Kittens love
microservices.
Microservices vaporize
unclean code.
Microservices make your
colleagues less annoying.
Microservices are
guaranteed bug-free.
6. Wait. What problem are we
actually trying to solve?
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
62. Should we decompose the front-end?
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
63. Should we decompose the front-end?
• Probably not.
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
64. Should we decompose the front-end?
• Probably not.
• Single Origin headaches
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
65. Should we decompose the front-end?
• Probably not.
• Single Origin headaches
• Page composition
headaches
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
69. REST != synchronous
(well, not necessarily)
• Synchronous is convenient
• Asynchronous has scalability
advantages
• Consider reactive
architectures
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
70. How hard the refactoring is
depends on where you started
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
71. Exposing a service
in a monolith
@ApplicationScoped
public class CatRepository {
public Set<Cat> getAllCats()
{
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
72. Exposing a
microservice
@Path("cat")
public class CatRepository {
@Path("allcats")
@Produces(MediaType.APPLICATION_JSON)
@GET
public Set<Cat> getAllCats() {
…
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
73. @Path("cat")
public class CatRepository {
@Path("allcats")
@Produces(MediaType.APPLICATION_JSON)
@GET
public Set<Cat> getAllCats() {
…
JAXRS=magic
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
74. Go asynchronous for scalability
@Path("allcats")
@Asynchronous
@GET
public void getAllCats(@Suspended final AsyncResponse response)
{
// stuff
response.resume(stuff)
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
76. Consuming a service in
a monolith
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
@Inject
CatRepository catRepo;
...
Set<Cat> cats = catRepo.getAllCats();
85. mymac:~ holly$ git submodule add ../catastrophe-interfaces
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
compile project(":catastrophe-interfaces")
Don’t do what I did :)
86. mymac:~ holly$ git submodule add ../catastrophe-interfaces
An anti-pattern
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
compile project(":catastrophe-interfaces")
Don’t do what I did :)
87. mymac:~ holly$ git submodule add ../catastrophe-interfaces
An anti-pattern
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
This is a code-layout
description, not a functional one
compile project(":catastrophe-interfaces")
Don’t do what I did :)
90. If this tradeoff is hurting, your
domain model is too coupled.
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
91. If this tradeoff is hurting, your
domain model is too coupled.
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
Have your microservices
got the right granularity?
93. “Does this domain model make sense?”
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
94. “Does this domain model make sense?”
“Not really.”
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
95. “Does this domain model make sense?”
“Not really.”
“Does decomposing a system of this
size into microservices actually make
sense?”
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
96. “Does this domain model make sense?”
“Not really.”
“Does decomposing a system of this
size into microservices actually make
sense?”
“Well, no.”
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
97. The right granularity
may be “monolith.”
“Does this domain model make sense?”
“Not really.”
“Does decomposing a system of this
size into microservices actually make
sense?”
“Well, no.”
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
109. ip address: special
ip address: precious
ip address: bespoke
ip address: lovely
ip address: fave
Network
topology
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
156. Have we tested it?
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
157. How de we handle failures?
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
158. Are we actually decoupled?
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
159. Are we actually decoupled?
@holly_cumminshttp://ibm.biz/bluemixgaragelondon
160. So remember…
• Decoupling is more than just HTTP
communication
• Some of your microservices will fail. Be resilient.
• I ♥ WebSphere Liberty
• JEE is great for microservices (especially with
microprofile)
• Hybrid cloud makes a lot of cool stuff possible
@holly_cumminshttp://ibm.biz/bluemixgaragelondon