Netflix OSS and Spring Cloud provide frameworks for building microservice applications that can run on various infrastructures. They include libraries like Eureka for service registration and discovery, Ribbon for load balancing, and Hystrix for fault tolerance via circuit breaking. Spring Cloud builds on Spring Boot and "Spring-ifies" Netflix libraries, providing a simple way to add features like configuration management and monitoring dashboards. These frameworks help developers implement microservices patterns in a transparent manner.
8. 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
9. Spring Boot
Spring Framework for the masses
No XML, no container (as you wish)
All the Spring stuff:
Dependency injection, transaction
management, REST, ...
10. Eureka server with Spring Boot
@SpringBootApplication
@EnableEurekaServer // activates Eureka
public class EurekaServer {
public static void main(String[] args) {
SpringApplication.run(EurekaServer.class,
args);
}
}
12. 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);
}
}
17. Circuit breaker: Hystrix
Why? To prevent cascading failure
How? async, detect failures, open/close
Where? Around services calls
18. 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
}
}