developing resilient cloud native apps with spring cloud

23
TECHNOLOGY SOLUTIONS DELIVERED Developing Resilient Cloud Native Apps with Spring Cloud Dallas Cloud Foundry Meetup Sept 28, 2015 Dustin Ruehle (@DustinRuehle)

Upload: dustin-ruehle

Post on 23-Jan-2017

494 views

Category:

Software


3 download

TRANSCRIPT

TECHNOLOGY SOLUTIONS DELIVERED

Developing  Resilient  Cloud  Native  Apps  with  Spring  Cloud  

Dallas  Cloud  Foundry  MeetupSept  28,  2015

Dustin  Ruehle (@DustinRuehle)

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

What  is  resilience?  

What  is  resilience?  

Spring  Cloud  Origins

Spring  Cloud  Origins

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

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

How  to  solve  the  “business”  problem?

“Cool  new  way”  service

“Old  way”  serviceEureka  Server  

Service  Registry

My  Landing  Page

11

2

2

33

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

How  to  solve  the  “business”  problem?

“Cool  new  way”  service

“Old  way”  serviceEureka  Server  

Service  Registry

My  Landing  Page

11

2

2

33

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

Runtime  Service  Discovery  with  Eureka•Register  and  discover  services  at  runtime•Registrations  stored  in  memory•Simple  dashboard  available•Spring  Boot  autoconfigurationfor  self-­registration•Can  be  used  to  look  up  external  config servers  automatically

@SpringBootApplication@EnableEurekaServerpublic  class  EurekaServerApplication {

public  static  void  main(String[]  args)  {            SpringApplication.run(EurekaServerApplication.class,  args

);}

}

A/B  Testing  Demo  – What  am  I  looking  at?

Pivotal  Web  Services:  cf-­dal-­meetup space

01Eureka

Server

Circuit  Breaker

Config Server

cloud-­demo-­service-­a

cloud-­demo-­ui

A/B  Testing  Demo  – What  am  I  looking  at?

Pivotal  Web  Services:  cf-­dal-­meetup space

01Eureka

Server

Circuit  Breaker

Config Server

cloud-­demo-­service-­a

cloud-­demo-­service-­b

cloud-­demo-­ui

cf push

cf map-route

Using  Hystrix to  Fail  Gracefully

source:  http://cloud.spring.io/spring-­cloud-­netflix/spring-­cloud-­netflix.html

Using  Hystrix to  Fail  Gracefully

source:  http://cloud.spring.io/spring-­cloud-­netflix/spring-­cloud-­netflix.html

Using  Hystrix to  Fail  Gracefully

source:  http://cloud.spring.io/spring-­cloud-­netflix/spring-­cloud-­netflix.html

CloudDemoUiApplication.java

Using  Hystrix to  Fail  Gracefully

source:  http://cloud.spring.io/spring-­cloud-­netflix/spring-­cloud-­netflix.html

CloudDemoUiApplication.java

UIController.java

Hystrix Demo  – What  am  I  looking  at?

Pivotal  Web  Services:  cf-­dal-­meetup space

01Eureka

Server

Circuit  Breaker

Config Server

cloud-­demo-­service-­a

cloud-­demo-­service-­b

cloud-­demo-­ui

Hystrix Demo  – What  am  I  looking  at?

Pivotal  Web  Services:  cf-­dal-­meetup space

01Eureka

Server

Circuit  Breaker

Config Server

cloud-­demo-­service-­a

cloud-­demo-­service-­b

cloud-­demo-­ui

cf delete -r

Hystrix Demo  – What  am  I  looking  at?

Pivotal  Web  Services:  cf-­dal-­meetup space

01Eureka

Server

Circuit  Breaker

Config Server

cloud-­demo-­service-­a

cloud-­demo-­service-­b

cloud-­demo-­ui

cf delete -r

Questions?

ReferencesTwelve  Factor  Apps:  http://12factor.netMicroservice Prereqs:  http://martinfowler.com/bliki/MicroservicePrerequisites.htmlSpring  Boot:  http://projects.spring.io/spring-­boot/Spring  Cloud:  http://projects.spring.io/spring-­cloud/Netflix  OSS:  http://netflix.github.io/

Blog:  http://www.ecsteam.com/ab-­testing-­using-­spring-­clouds-­eureka-­and-­blue-­green-­deployments-­in-­cloud-­foundrySource  for  this  Demo:  https://github.com/ECSTeam/spring-­cloud-­demo

Ted  Talk:  http://www.lifehack.org/294043/the-­most-­funny-­ted-­talk-­ever-­teach-­you-­how-­sound-­smart?n=1&ref=tp

Thank  You!

Special  Thanks  to  Josh  Ghiloni (@joshghiloni)  for  his  cool  demo  code