Tuesday, May 18, 2021

Spring Cloud Interview Questions

What are the benefits of using cloud ?

·       It is cost effective. Economies of scale in acquisition of equipment, utilities and maintaining.

·       Abstracts infrastructure complexity. We can use or resources on our application functional requirements instead of maintaining infrastructure or platforms.

·       It provides Scalability so that no matter how efficient your provider and your IT team is, using cloud providers we can scale dynamically.

·       Cloud providers offer a better service level than the best private infrastructure we could afford.

What is Spring Cloud ?

·       Cloud is used in every business organization for hosting. It was important to introduce cloud in the path of Spring too.

·       Spring Cloud Stream App Starters are Spring Boot based Spring Integration applications that provide integration with external systems.

·       A short-lived microservices framework to quickly build applications that perform finite amounts of data processing.

What is Spring Cloud Netflix?

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?

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 does one mean by Service Registration and Discovery? How is it implemented in Spring Cloud ?

·       When we start a project, we usually have all the configurations in the properties file.

·       When more and more services are developed and deployed then adding and modifying these properties become more complex.

·       Some services might go down, while some the location might change. This manual changing of properties may create problems.

·       Eureka Service Registration and Discovery helps in such cases.

·       As all services are registered to the Eureka server and lookup done by calling the Eureka Server, any change in service locations need not be handled and is taken care of Microservice Registration and Discovery with Spring cloud using Netflix Eureka.

Mention few benefits for service discovery mechanism?

  • Availability : Service lookups is shared among all nodes of service discovery cluster. So even a node becomes unavailable then others node take over.
  • Sharing Instances : each node in cluster shares instances of services.
  • Fault tolerant : If any service instance is not healthy then service discovery removes it from its table.
  • Load balanced : Service discovery ensures that when when service invocation happens then invocation is spread across all instances.

What is Netflix Feign?
Feign is a declarative web service client. It makes writing web service clients easier. To use Feign create an interface and annotate it.

What is netflix feign advantages?
Netflix provides Feign as an abstraction over REST-based calls, by which microservices can communicate with each other, however developers don't have to bother about REST internal details.

What is Eureka?

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?

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?

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?

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?

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?

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


What are the different kinds of filters provided by Zuul?

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.


No comments:

Post a Comment