This document discusses how Netflix OSS and Spring Cloud can be used together to implement a microservices architecture. It describes various libraries like Eureka for service discovery, Hystrix for circuit breaking, Ribbon for load balancing, and Zuul for API gateway functionality. It also explains how Spring Boot simplifies application development and Spring Cloud integrates these Netflix libraries and provides additional features like a configuration server. Overall, Netflix OSS and Spring Cloud provide the tools needed to build resilient microservices with service discovery, load balancing, and other capabilities in a transparent way for developers.
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
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. Spring Boot
Spring Framework for the masses
No XML, no container (as you wish)
All the Spring stuff:
Dependency injection, transaction
management, REST, ...
12. Eureka server with Spring Boot
@SpringBootApplication
@EnableEurekaServer // activates Eureka
public class EurekaServer {
public static void main(String[] args) {
SpringApplication.run(EurekaServer.class, args);
}
}
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);
}
}
19. Circuit breaker: Hystrix
Why? To prevent cascading failure
How? async, detect failures, open/close
Where? Around services calls
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
}
}
28. API gateway (reverse proxy)
Browser
Static content
Frontend
(app.js)
Backend service
REST calls
REST calls forwarding
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
34. Configuration server in Spring Boot
@SpringBootApplication
@EnableConfigServer
public class ConfigurationServer {
public static void main(String[] args) {
SpringApplication.run(ConfigurationServer.class,args);
}
}
35. From files to HTTP endpoints
$ tree --charset ascii
.
|-- application.yml
|-- backend-service.yml
`-- front-application.yml