Spring Cloud Netflix - Interview Questions

What is Spring Cloud Netflix?

 FAQKey Concept

Spring Cloud Netflix, part of Spring cloud platform, provides Netflix OSS integrations for Spring Boot apps.

Using annotations you can quickly enable and configure the common cloud patterns inside your application and build large distributed systems using Netflix OSS components.

The patterns supported by Spring Cloud Netflix include Service Discovery (Eureka), Circuit Breaker (Hystrix), Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon)

What are the key capabilities provided in Spring Cloud Netflix?

 FAQKey Concept

Spring Cloud Netflix has the following key capabilities.

1. Service Discovery - Spring Cloud Netflix framework provides the capability to register Eureka instances, which clients can discover using spring managed beans.

2. Circuit Breaker - Spring Cloud Netflix framework provides a simple annotation-driven method decorator to build Hystrix clients.

3. Declarative REST Client - Spring Cloud Netflix framework provides support for Feign which creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations.

4. Client Side Load Balancer - Spring Cloud Netflix framework provides support for Ribbon, a client side load balancer provided in the Netflix OSS platform.

5. Router and Filter - Spring Cloud Netflix framework provides support for automatic registration of Zuul filters, and a simple convention over configuration approach to reverse proxy creation.

What is Eureka?

 FAQKey Concept

Eureka is a Service Discovery Server and Client provided in the Netflix OSS platform. Service Discovery is one of the key tenets of a microservice-based cloud architecture.

How do you include Eureka in your project?

 FAQKey Concept

To include the Eureka Client in your project, use spring-cloud-starter-netflix-eureka-client dependency and @EnableEurekaClient annotation on the Spring Boot Application class.

To include the Eureka server in your project, use spring-cloud-starter-eureka-server dependency and @EnableEurekaServer annotation on the Spring Boot Application class.

What is Hystrix?

 FAQKey Concept

Hystrix is a library developed by Netflix that implements the Circuit Breaker pattern.

In a microservice architecture, it is common to have multiple layers of service calls, i.e one microservice can call multiple downstream microservices. A service failure in any one of the lower level services can cause cascading failure all the way up to the user.

Circuit Breaker pattern provides a fallback mechanism, which avoids cascading of failures up to the user.

How do you include Hystrix in your project?

 FAQKey Concept

To include Hystrix in your project, use spring-cloud-starter-netflix-hystrix dependency and @EnableCircuitBreaker annotation on the Spring Boot Application class.

Use the @HystrixCommand annotation on the method for which fallback method has to be applied.

What is Zuul?

 FAQKey Concept

Zuul is a JVM-based router and server-side load balancer developed by Netflix and included in the Netflix OSS package.

How do you include Zuul in your project?

 FAQKey Concept

To include Hystrix in your project, use the spring-cloud-starter-netflix-zuul dependency.

What are the different kinds of filters provided by Zuul?

 FAQKey Concept

Zuul provides the following filter types that correspond to the lifecycle of a request.

1. PRE Filters - Filters that execute before routing to the origin server.

2.ROUTING Filters - Filters that handle routing the request to an origin. Builds HTTP Request and calls the Origin server using Apache HttpClient or Netflix Ribbon.

3. POST Filters - Filters that execute after the request has been routed to the origin.

4. ERROR Filters - Filters that execute when an error occurs during any one of the phases.