Top Spring Cloud Interview Questions (2021)
- What is need for Cloud?
- What are the benefits of using cloud?
- What is Spring Cloud?
- What are the features of Spring Cloud?
- What is Spring Cloud Ribbon?
- What is Spring Cloud Config?
- What is Spring Cloud Consul?
- What is the use of Spring Cloud stream?
- What does one mean by Service Registration and Discovery? How is it implemented in Spring Cloud?
- Which design pattern are used in Microservices?
- What is Netflix Feign? What are its advantages?
- What is Eureka in Spring Cloud?
- What is the purpose of the Hystrix circuit breaker?
- What is the use of the Spring cloud bus?
- What does service registration and discovery mean? How is Spring Cloud implemented?
- Name the features of using Spring Boot?
- What is RAD model?
- What is microservice?
- What is a service fuse? What is service degradation
- 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.
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.
- 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.
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 BalancersThere 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
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.
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.
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-
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 application.properties 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.
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
- 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 degradationThe 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.