Top Spring Cloud Interview Questions (2021) | CodeUsingJava

Top Spring Cloud Interview Questions (2021)

  1. What is need for Cloud?
  2. What are the benefits of using cloud?
  3. What is Spring Cloud?
  4. What are the features of Spring Cloud?
  5. What is Spring Cloud Ribbon?
  6. What is Spring Cloud Config?
  7. What is Spring Cloud Consul?
  8. What is the use of Spring Cloud stream?
  9. What does one mean by Service Registration and Discovery? How is it implemented in Spring Cloud?
  10. Which design pattern are used in Microservices?
  11. What is Netflix Feign? What are its advantages?
  12. What is Eureka in Spring Cloud?
  13. What is the purpose of the Hystrix circuit breaker?
  14. What is the use of the Spring cloud bus?
  15. What does service registration and discovery mean? How is Spring Cloud implemented?
  16. Name the features of using Spring Boot?
  17. What is RAD model?
  18. What is microservice?
  19. What is a service fuse? What is service degradation
  20. How does Spring Cloud Gateway Limit Request Payload Size?

What is need for Cloud?

  • Cloud has taken over most of the hosting servers into a single large server space.
  • Cloud computing is similar to traditional hosting, which makes use of the single dedicated server, while cloud computing uses virtualization technology to pool or share resources from the underlying network of the physical servers.
  • It is the kind of computing that relies on shared computing resources instead of local servers and personal devices.

need for Cloud

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 is your provider and your IT team, 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 are the features of Spring Cloud?

Spring Cloud has the following features:
  • Versioned and distributed configuration.
  • Discovery of service registration.
  • Service to service calls.
  • Routing.
  • Circuit breakers and load balancing.
  • Cluster state and leadership election.

What is the use of Spring Cloud stream ?

  • Spring cloud stream allows to integrate microservices with message brokers.

Spring Cloud benefits

What is Spring Cloud Ribbon?

One can scale microservice architecture application in both vertical i.e. by increasing the allocation of heap memory as well as horizontal i.e. by making more then one instances available of same service.
Horizontal scaling is done by the help of Load Balancers.

Load Balancers

There may be situation when there is need to create numerous replicas. This is usually done to manage the traffic by the users.As the name suggest, Load Balancers helps in equal distribution of the traffic.
Types of Load Balancers

Load balancing
Netflix Ribbon is one of the library of cloud that helps in providing the client side load balancing.
It uses some criteria and then decide which server to send the request.
Basic Ribbon diagram
In this example, we will be implementing Netflix Ribbon in a spring boot application. We will be calling instance of demo application multiple times(here 3 times), and then with the help of LoadBalancer Application, the process of Load Balancing will be done and multiple instances will be managed.
The algorithm uses by Netflix Ribbon for load balancing is Round Robin algorithm.
Spring Cloud With Netflix Ribbon

What is Spring Cloud Config?

In an Enterprise Application, many microservices collaborate together so Just keeping our configuration stored in a enviornment sometimes does not prove to be a good option.
Here is where the Spring cloud config server comes to use. In the spring cloud config, there is a centralised server responsible where multiple services can be configured.
Spring Config Project
In this project we will have InfoManager which acts as a client, InfoByAuthorities class which acts as a information source and InfoConfiguration class which acts as a configuration server and we will configure our git server here.
The project flow can be described as follows-
Spring Config Project
The client instance will not directly communicate with the information source . Instead they will communicate with a config server which further communicate through github. The github will now communicate with InfoByAuthorities service.
The advantage is that any changes in the url of InfoByAuthorities would not directly affect the InfoManager. The github repository will take care of the changes and reflect automatically.
Firstly open your github and create a repository named InfoServer. Now create a file named in it.
Spring Cloud With Config

What is Spring Cloud Consul?

In this tutorial we will be implementing a Spring Cloud Consul using Spring Cloud.
Consul is one of the products of HashiCorp. Spring consul provides an easy way by which one can register instances as consul agent and that instances can be further discovered by clients using spring beans. There are sveral features provided by consul. Some of them includes configuration management with the use of Key/Value store , health checking etc. are provided by the consul.
Let us understand by a sceanerio of a system without the consul and a system using consul.
Sceanerio without consul
Case 1- Services without consul
Sceanerio with consul
Case 2- Services with consul
We can clearly see that with the help of consul, a centralised configuration can be done. Multiple environment support is provided by the consul.Consul also provides the benifit of instance update.
Firstly we need to download the consul agent. Now we need to find the ip address of our system.
Now run the following command in command prompt.
Now run the following url
You would see the consul running. Now we create the spring boot project and register their instance in the consul.
we will create two services and register their instances in consul.
Spring Cloud Consul Service and Discovery

What does one mean by Service Registration and Discovery? How is it implemented in Spring Cloud ?

  • When we start a project, we usally 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.

Spring Cloud With Netflix Eureka

Which design pattern are used in Microservices ?

  • Aggregator Microservice Design Pattern
  • Proxy Microservice Design Pattern
  • Chained Microservice Design Pattern
  • Branch Microservice Design Pattern
  • Shared Data Microservice Design Pattern
  • Asynchronous Messaging Microservice Design Pattern

What is Netflix Feign? What are its advantages?

Feign is a java to http client binder inspired by Retrofit, JAXRS-2.0, and WebSocket. Feign's first goal was reducing the complexity of binding Denominator uniformly to http apis regardless of restfulness. Previous examples in the employee-consumer we consumed the REST services exposed by the employee-producer using REST Template

What is Eureka in Spring Cloud ?

  • Eureka Server is an application which holds the information about all client-service applications.
  • Every Micro service will register into the Eureka server and Eureka server knows all the client applications running on each port and IP address.

What is the purpose of the Hystrix circuit breaker?

Netflix's Hystrix library provides an implementation of the circuit breaker pattern. If you apply a circuit breaker to a method, Hystrix watches for failing calls to that method, and, if failures build up to a threshold, Hystrix opens the circuit so that subsequent calls automatically fail.
The purpose of the Hystrix circuit breaker is to provide the first-page method or any other methods that the method in the first page might be calling and is causing the exception to recover. The chances of exception to recovery may increase because of less load. You can further see Master Microservices with Spring Boot and Spring Cloud course to learn more about Fault tolerance.
Spring Cloud With Hysterix Circuit Breaker

What is the use of the Spring cloud bus?

Spring Cloud Bus links the nodes of a distributed system with a lightweight message broker.A key idea is that the bus is like a distributed actuator for a Spring Boot application that is scaled out.It can also be used as a communication channel between apps.
Spring Cloud is a framework for building robust cloud applications.Applications that run with microservices architecture aim to simplify development, deployment, and maintenance. The decomposed nature of the application allows developers to focus on one problem at a time.

What does service registration and discovery mean? How is Spring Cloud implemented?

As more and more services are developed and deployed, adding and modifying these attributes becomes more complicated. Some services may decline, while certain locations may change. Manually changing attributes may cause problems. Eureka service registration and discovery can help in this situation. Since all services are registered on the Eureka server and found by calling the Eureka server, there is no need to deal with any changes and processing of the service location.


Name the features of using Spring Boot?

Features of using Spring Boot are:
  • Starter dependency
  • Auto-configuration
  • Spring initializer

What is RAD model?

The Rapid Application Development model is based on prototyping and iterative model with less specific planning. In general, RAD approach to software development means putting lesser emphasis on planning tasks and more emphasis on development and coming up with a prototype.
RAD should be used only when a system can be modularized to be delivered in an incremental manner. It should be used only if the budget permits use of automated code generating tools.

What is microservice?

Microservice architecture is an architectural pattern or an architectural style. It advocates the division of a single application into a set of small services. Each service runs in its own process. The services coordinate and coordinate with each other. Cooperate to provide users with ultimate value. Lightweight communication mechanisms are used to communicate with each other. Each service is built around a specific business and can be independently constructed in a production environment or production-like environment.
In addition, a unified and centralized service management mechanism should be avoided. For a specific service, the appropriate language and tools should be selected according to the business context to build it. There can be a very lightweight centralized management to To coordinate these services, you can use different languages to write services, or you can use different data stores.

What is a service fuse? What is service degradation

The fuse mechanism is a microservice link protection mechanism that responds to the avalanche effect. When a microservice is unavailable or the response time is too long, the service will be downgraded, and then the call of the microservice of the node will be fused, and the error response information will be quickly returned.
Service degradation is generally considered from the overall load. That is, when a service is broken, the server will no longer be called, at this time the client can prepare a local fallback callback and return a default value. In doing so, although the level drops, it is still available anyway, which is better than just hanging it out.

service fuse

How does Spring Cloud Gateway Limit Request Payload Size?

Spring Cloud Gateway is built on Spring Boot 2.x, Spring WebFlux, and Project Reactor.It is the permissible size limit of the request defined in bytes. ... filter filter to modify the request body before it is sent downstream by the gateway.