Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Microservices with Netflix OSS and Spring Cloud - Dev Day Orange

0 views

Published on

Presentation on microservices at the "Dev Day Orange" - Lyon - October 2015

Published in: Technology

Microservices with Netflix OSS and Spring Cloud - Dev Day Orange

  1. 1. Microservices with Netflix OSS & Spring Cloud Arnaud Cogoluègnes Lyon, October 6th, 2015
  2. 2. Microservices with Netflix OSS & Spring Cloud Arnaud Cogoluègnes Spring Framework Spring Boot Spring Cloud Eureka, Hystrix, Zuul, Ribbon Service discoveryCircuit breaker Load balancing API gateway Configuration server
  3. 3. Speaker: Arnaud Cogoluègnes
  4. 4. Netflix OSS and Spring Cloud aren’t limited to the cloud infrastructure or container solutions
  5. 5. Netflix OSS and Spring Cloud are application frameworks also valid for traditional applications open source
  6. 6. Docker Container Docker Container Where does it fit? Spring Boot Application (Netflix OSS & Spring Cloud) Java Virtual Machine Eureka Service Registry Java Virtual Machine Infrastructure (Mesos, vanilla datacenter, VM, Cloud Foundry, AWS, laptop)
  7. 7. The use case Frontend Backend (instance 1) Backend (instance 2) Service registry (Eureka) Discovers Registers Registers Balances
  8. 8. Wishlist Packaging Security Service discovery Monitoring Continuous deployment Resiliency Centralized logging Centralized configuration
  9. 9. Netflix stack Eureka (service registry) Hystrix (circuit breaker) Ribbon (client load balancer) Zuul (proxy) ....
  10. 10. Spring Cloud Built on top of Spring Boot Spring-ifies some nifty libraries (e.g. Netflix) Provides goodies (e.g. configuration server) Pretty much all you need for microservices
  11. 11. Spring Boot Spring Framework for the masses No XML, no container (as you wish) All the Spring stuff: Dependency injection, transaction management, REST, ...
  12. 12. Eureka server with Spring Boot @SpringBootApplication @EnableEurekaServer // activates Eureka public class EurekaServer { public static void main(String[] args) { SpringApplication.run(EurekaServer.class, args); } }
  13. 13. Eureka server Frontend Backend (instance 1) Backend (instance 2) Service registry (Eureka)
  14. 14. Eureka client with Spring Cloud @SpringBootApplication @EnableEurekaClient // application registers to Eureka public class BackendServiceApplication { public static void main(String[] args) { SpringApplication.run(BackendServiceApplication.class, args); } }
  15. 15. Eureka client Frontend Backend (instance 1) Backend (instance 2) Service registry (Eureka) Discovers Registers Registers
  16. 16. REST client call @Repository public class ContactRepository { @Autowired RestTemplate restClient; public ContactsResponse contacts() { ContactsResponse response = restClient.getForObject( "http://backend-service/contacts", // host = service name ContactsResponse. class ); response.setOk( true); return response; }
  17. 17. Client load balancer: Ribbon Handles HTTP requests Balances load and detects failures Resolves services from Eureka
  18. 18. Client load balancing Frontend Backend (instance 1) Backend (instance 2) Service registry (Eureka) Balances
  19. 19. Circuit breaker: Hystrix Why? To prevent cascading failure How? async, detect failures, open/close Where? Around services calls
  20. 20. Hystrix with Spring Cloud @Repository public class ContactRepository { @HystrixCommand(fallbackMethod = "contactsFailure") public ContactsResponse contacts() { // real call (protected by circuit breaker) } public ContactsResponse contactsFailure() { // fallback, when real call fails } }
  21. 21. Circuit breaker Frontend Backend (instance 1) Backend (instance 2) Service registry (Eureka)
  22. 22. Hystrix activation @SpringBootApplication @EnableCircuitBreaker // protects targeted methods @EnableEurekaClient @EnableHystrixDashboard // enables dashboard public class FrontApplication { public static void main(String[] args) { SpringApplication.run(FrontApplication.class,args); } }
  23. 23. Hystrix dashboard Source: https://github.com/Netflix/Hystrix
  24. 24. Hystrix dashboard explained Source: https://github.com/Netflix/Hystrix
  25. 25. Hystrix dashboard aggregation Source: https://github.com/Netflix/Hystrix
  26. 26. Source: https://github.com/Netflix/Hystrix
  27. 27. JavaScript application Browser Static content Frontend (app.js) Backend service REST calls CORS? Security?
  28. 28. API gateway (reverse proxy) Browser Static content Frontend (app.js) Backend service REST calls REST calls forwarding
  29. 29. API gateway with Spring Cloud Browser Static content Frontend (app.js) Backend service REST calls REST calls fowarding Handled by Netflix’s Zuul in frontend
  30. 30. Eureka-aware API gateway Browser Static content Frontend (app.js) Backend service REST calls REST calls forwarding Eureka Discovers Registers
  31. 31. Zuul API gateway activation @SpringBootApplication @EnableCircuitBreaker @EnableEurekaClient @EnableHystrixDashboard @EnableZuulProxy // activates Zuul API gateway public class FrontApplication { public static void main(String[] args) { SpringApplication.run(FrontApplication.class,args); } }
  32. 32. Configuration server HTTP Service 1 Service 2 Service 3 Configuration server Git repository
  33. 33. Configuration server The only local parameter of a service For DB URL, password, thread pool size, etc.
  34. 34. Configuration server in Spring Boot @SpringBootApplication @EnableConfigServer public class ConfigurationServer { public static void main(String[] args) { SpringApplication.run(ConfigurationServer.class,args); } }
  35. 35. From files to HTTP endpoints $ tree --charset ascii . |-- application.yml |-- backend-service.yml `-- front-application.yml
  36. 36. Configuration on the client side
  37. 37. Packaging with Docker mvn clean package # Dockerfile FROM java:openjdk-8u45-jre MAINTAINER arnaud.cogoluegnes@zenika.com RUN mkdir /microservice ADD ./target /microservice WORKDIR /microservice ENTRYPOINT ["java", "-jar", "/microservice/backend-service-1.0.jar"]
  38. 38. Wishlist Packaging Security Service discovery Monitoring Continuous deployment Resiliency Centralized logging Centralized configuration
  39. 39. Summary Mature, battle-tested libraries Help to implement microservices architecture Transparent for the developper
  40. 40. Questions?
  41. 41. Thank you!

×