Distributed and massively scalable systems are difficult to design, implement, and operate. Further, microservice architectures are supposed to enable your business to be disruptive and innovative. Thankfully, two communities have emerged to facilitate easier solutions for these concerns and do a lot of the work for you: Spring Cloud OSS and Cloud Foundry. In this talk, we will take a deeper look at preventing cascading failures using Hystrix, as well as illustrate a mechanism for A/B testing using Eureka and blue-green deployments on Cloud Foundry.
2. What are we covering today?
•What does it mean to be resilient?
•Spring Cloud Origins
•Why Spring Cloud?
•A/B Testing using Eureka and CF
•Using Hystrix to Fail Gracefully
7. Why Spring Cloud?
Microservice architectures are complex!
• They need to have their config stored in the environment, not in code
• Microservices are loosely coupled – They need to discover and be discoverable
• They are not necessarily colocated – Inter-service communication needs to be fault-tolerant
Netflix is a microservice architecture …
“they (probably) didn't build all this just because they were bored”
@joshghiloni
8. The “business” problem
“Cool new
way” service
Users of
“Old way”
Users of “cool
new way”
My Landing
Page
“Old way”
service
19% conversion
79% conversion
J
L
9. How to solve the “business” problem?
“Cool new
way” service
“Old way”
serviceEureka Server
Service
Registry
My Landing
Page
1
1
2
2
3
3
Register
Discover
Connect
Go
Routers
“Old way”
service
“Cool new
way” service
1
2
3
1
Existing app -
myservice.foo.com
2
New app -
myservice-B.foo.com
3
Map route -
myservice.foo.com
10. How to solve the “business” problem?
“Cool new
way” service
“Old way”
serviceEureka Server
Service
Registry
My Landing
Page
1
1
2
2
3
3
Register
Discover
Connect
Go
Routers
“Old way”
service
“Cool new
way” service
1
2
3
1
Existing app -
myservice.foo.com
2
New app -
myservice-B.foo.com
3
Map route -
myservice.foo.com
application.yml
11. Runtime Service Discovery with Eureka
•Register and discover
services at runtime
•Registrations stored in
memory
•Simple dashboard available
•Spring Boot autoconfiguration
for self-registration
•Can be used to look up
external config servers
automatically
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(
EurekaServerApplication.class,
args
);
}
}
12. A/B Testing Demo – What am I looking at?
Pivotal Web Services: cf-dal-meetup space
0
1
Eureka
Server
Circuit Breaker
Config Server
cloud-demo-service-a
cloud-demo-ui
13. A/B Testing Demo – What am I looking at?
Pivotal Web Services: cf-dal-meetup space
0
1
Eureka
Server
Circuit Breaker
Config Server
cloud-demo-service-a
cloud-demo-service-b
cloud-demo-ui
cf push
cf map-route
14. Using Hystrixto Fail Gracefully
source: http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html
15. Using Hystrixto Fail Gracefully
source: http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html
16. Using Hystrixto Fail Gracefully
source: http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html
CloudDemoUiApplication.java
17. Using Hystrixto Fail Gracefully
source: http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html
CloudDemoUiApplication.java
UIController.java
18. Hystrix Demo – What am I looking at?
Pivotal Web Services: cf-dal-meetup space
0
1
Eureka
Server
Circuit Breaker
Config Server
cloud-demo-service-a
cloud-demo-service-b
cloud-demo-ui
19. Hystrix Demo – What am I looking at?
Pivotal Web Services: cf-dal-meetup space
0
1
Eureka
Server
Circuit Breaker
Config Server
cloud-demo-service-a
cloud-demo-service-b
cloud-demo-ui
cf delete -r
20. Hystrix Demo – What am I looking at?
Pivotal Web Services: cf-dal-meetup space
0
1
Eureka
Server
Circuit Breaker
Config Server
cloud-demo-service-a
cloud-demo-service-b
cloud-demo-ui
cf delete -r