Microservices make your colleagues less annoying.
Microservices are guaranteed bug-free.
Microservices: Good design built-in! Kittens love microservices.
Microservices vaporize unclean code.
Microservices. The best thing since sliced bread. Every microservice comes with a free puppy. http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 6
Wait. What problem are we actually trying to solve?
http://ibm.biz/bluemixgaragelondon
@holly_cummins
What happens if things fail?
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 56
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 57
Refactoring your way to the microservices dream
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 58
http://github.com/holly-cummins/catastrophe-microservices
Slice it up! http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 59
http://github.com/holly-cummins/catastrophe-microservices
Slice it up! http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 60
http://github.com/holly-cummins/catastrophe-microservices
HTTP
HTTP
HT
TP
Slice it up! http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 61
http://github.com/holly-cummins/catastrophe-microservices
HTTP
HTTP
HT
TP
Peel it off. http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 62
Should we decompose the front-end? http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 63
•
Probably not.
Should we decompose the front-end? http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 64
•
Probably not. •
Single Origin headaches
Should we decompose the front-end? http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 65
•
Probably not. •
Single Origin headaches
•
Page composition headaches
Should we decompose the front-end? http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 66
REST
REST
http://ibm.biz/bluemixgaragelondon
RE
ST
@holly_cummins
Slide 67
Message
REST
http://ibm.biz/bluemixgaragelondon
RE
ST
@holly_cummins
Slide 68
REST
REST
http://ibm.biz/bluemixgaragelondon
RE
ST
@holly_cummins
Slide 69
•
Synchronous is convenient
•
Asynchronous has scalability advantages
•
Consider reactive architectures
REST != synchronous (well, not necessarily) http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 70
How hard the refactoring is depends on where you started
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 71
@ApplicationScoped public class CatRepository { public Set<Cat> getAllCats() {
Exposing a service in a monolith http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 72
@Path(“cat”) public class CatRepository { @Path(“allcats”) @Produces(MediaType.APPLICATION_JSON) @GET public Set<Cat> getAllCats() { …
Exposing a microservice http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 73
@Path(“cat”) public class CatRepository { @Path(“allcats”) @Produces(MediaType.APPLICATION_JSON) @GET public Set<Cat> getAllCats() { …
JAXRS=magic http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 74
@Path(“allcats”) @Asynchronous @GET public void getAllCats(@Suspended final AsyncResponse response) { // stuff response.resume(stuff)
Go asynchronous for scalability http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 75
@Path(“allcats”) @Asynchronous @GET public void getAllCats(@Suspended final AsyncResponse response) { // stuff response.resume(stuff)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 76
@Inject CatRepository catRepo; … Set<Cat> cats = catRepo.getAllCats();
Consuming a service in a monolith http://ibm.biz/bluemixgaragelondon
@holly_cummins
Don’t forget to slice up the database too http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 79
REST
REST
http://ibm.biz/bluemixgaragelondon
RE
ST
@holly_cummins
Slide 80
REST
REST
http://ibm.biz/bluemixgaragelondon
RE
ST
@holly_cummins
Slide 81
Are we done?
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 82
Don’t forget to slice up the data model too
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 83
Don’t do what I did :)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 84
compile project(“:catastrophe-interfaces”)
Don’t do what I did :)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 85
compile project(“:catastrophe-interfaces”) mymac:~ holly$ git submodule add ../catastrophe-interfaces
Don’t do what I did :)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 86
An anti-pattern
compile project(“:catastrophe-interfaces”) mymac:~ holly$ git submodule add ../catastrophe-interfaces
Don’t do what I did :)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 87
An anti-pattern
compile project(“:catastrophe-interfaces”) mymac:~ holly$ git submodule add ../catastrophe-interfaces
Don’t do what I did :)
http://ibm.biz/bluemixgaragelondon
This is a code-layout description, not a functional one @holly_cummins
Slide 88
Duplication of code
Decoupling
The tradeoff http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 89
Duplication of code
Compile-time independence
The tradeoff http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 90
If this tradeoff is hurting, your domain model is too coupled.
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 91
If this tradeoff is hurting, your domain model is too coupled.
Have your microservices got the right granularity? http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 92
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 93
“Does this domain model make sense?”
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 94
“Does this domain model make sense?” “Not really.”
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 95
“Does this domain model make sense?” “Not really.” “Does decomposing a system of this size into microservices actually make sense?”
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 96
“Does this domain model make sense?” “Not really.” “Does decomposing a system of this size into microservices actually make sense?” “Well, no.”
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 97
“Does this domain model make sense?” “Not really.” “Does decomposing a system of this size into microservices actually make sense?” “Well, no.”
The right granularity may be “monolith.” http://ibm.biz/bluemixgaragelondon
@holly_cummins
WebTarget cat = client.target(“http://raspberrypiclearcase.local”); WebTarget auth = client.target(“http://raspberrypi2.local”); WebTarget scoring = client.target(“http://raspberrypiredcase.local”);
This is robust code, right?
Slide 108
ip add r
ess: ? .?.?.?
ip address: ?.?.?.?
ip address: ?.?.?.? ip add r
ess: ? .?.?.?
ip address: ?.?.?.?
Network topology http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 109
ip add r
ess: s
pecial
ip address: bespoke
ip address: precious ip add r
ess: lo vely
ip address: fave
Network topology http://ibm.biz/bluemixgaragelondon
@holly_cummins
Disposability Say no to snowflake servers http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 113
Disposability Say no to snowflake servers http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 114
ip add r
ess: s
pecial
ip address: bespoke
ip address: precious ip add r
ess: lo vely
ip address: fave
Scaling http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 115
ip add r
ess: s
pecial
ip address: bespoke
ip address: precious ip add r
ess: lo vely
ip address: fave
Scaling http://ibm.biz/bluemixgaragelondon
ip add r
ess: lo nely
@holly_cummins
Slide 116
ip add r
ess: s
pecial
ip address: bespoke
ip address: precious ip add r
ess: lo vely
ip address: fave
Scaling http://ibm.biz/bluemixgaragelondon
ip add r
ess: lo nely
@holly_cummins
Slide 117
•
Kubernetes
•
Apache Zookeeper + Curator
•
Eureka
•
etcd
•
Consul
•
Bluemix Service Discovery
Service discovery
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 118
•
Docker Kubernetes
•
Apache Zookeeper + Curator
•
Eureka
•
etcd
•
Consul
•
Bluemix Service Discovery
Service discovery
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 119
•
Docker Kubernetes
•
Apache Zookeeper + Curator Java
•
Eureka
•
etcd
•
Consul
•
Bluemix Service Discovery
Service discovery
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 120
•
Docker Kubernetes
•
Apache Zookeeper + Curator Java
•
EurekaAWSSoftLayer
•
etcd
•
Consul
•
Bluemix Service Discovery
Service discovery
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 121
•
Docker Kubernetes
•
Apache Zookeeper + Curator Java
•
EurekaAWSSoftLayer
•
etcd CoreOS
•
Consul
•
Bluemix Service Discovery
Service discovery
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Server configuration
<featureManager> <feature>jaxrs-1.0</feature> <feature>usr:discovery</feature> …
Wouldn’t this be nice?
<consul server=”catastrophe.consul” /> http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 133
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 134
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 135
Liberty extension (“user feature”)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 136
Liberty extension (“user feature”)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 137
Autopublishes REST endpoints
Liberty extension (“user feature”)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 138
Autopublishes REST endpoints
I
WebSphere Liberty extensibility Liberty https://github.com/WASdev/sample.consulservicediscovery extension (“user feature”)
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 139
“Type a quote here.” –Johnny Appleseed
Consul view of the Catastrophe services http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 140
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 141
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 142
You need DevOps http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 143
An SD card is not devops :)
You need 100% automation http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 144
“Type a quote here.” –Johnny Appleseed
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 145
“Type a quote here.” –Johnny Appleseed
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 146
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 147
http://catastrophe-web.mybluemix.net/
Slide 148
Who can draw the best cat? http://catastrophe-web.mybluemix.net/ (I have THINK hats for the highest scores!)
Slide 149
What if I want to run on both pis and the cloud?
Slide 150
What if I want to run on both pis and the cloud?
You need Hybrid Cloud!
Slide 151
What if I want to run on both pis and the cloud?
“Type a quote here.” –Johnny Appleseed
You need Hybrid Cloud!
Slide 152
Slide 153
Slide 154
Are we done? http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 155
Consul
Discovery REST
Dis cov
Discovery REST
ery
RE
ST
Are we done? http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 156
Have we tested it?
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 157
How de we handle failures?
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 158
Are we actually decoupled?
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 159
Are we actually decoupled?
http://ibm.biz/bluemixgaragelondon
@holly_cummins
Slide 160
So remember…
http://ibm.biz/bluemixgaragelondon
•
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_cummins