Q: How will you monitor multiple microservices for various indicators like health?
Spring Boot provides actuator endpoints to monitor metrics of individual microservices. These endpoints are very helpful for getting information about applications
like if they are up, if their components like database etc are working good. But a major drawback or difficulty about using actuator enpoints is that
we have to individually hit the enpoints for applications to know their status or health. Imagine microservices involving 50 applications, the admin will have
to hit the actuator endpoints of all 50 applications. To help us deal with this situation, we will be using open source project located at https://github.com/codecentric/spring-boot-admin
Built on top of Spring Boot Actuator, it provides a web UI to enable us visualize the metrics of multiple applications.
Spring Boot Admin Example
Q: What does one mean by Service Registration and Discovery ? How is it implemented in Spring
When we start a project, we usally have all the configurations in the properties file.
As more and more services are developed and deployed,
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 issues.
Eureka Service Registration and Discovery helps in such scenarios.
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.
Q: What are the different Microservices Design Patterns?
The different Microservices Design Patterns are -
Q: What does one mean by Load Balancing ? How is it implemented in Spring
Aggregator Microservice Design Pattern
API Gateway Design Pattern
Chain of Responsibility Design Pattern
Branch Microservice Design Pattern
Circuit Breaker Design Pattern
Asynchronous Messaging Design Pattern
In computing, load balancing improves the distribution of workloads across multiple computing resources,
such as computers, a computer cluster, network links, central processing units, or disk drives.
Load balancing aims to optimize resource use, maximize throughput, minimize response time, and avoid overload
of any single resource. Using multiple components with load balancing instead of a single component may increase
reliability and availability through redundancy. Load balancing usually involves dedicated software or hardware,
such as a multilayer switch or a Domain Name System server process.
In SpringCloud this can be implemented using Netflix Ribbon.
Spring Cloud- Netflix Eureka + Ribbon Simple Example
Q: How to achieve server side load balancing using Spring Cloud?
Server side load balancingcan be achieved using Netflix Zuul.
Zuul is a JVM based router and server side load balancer by Netflix.
It provides a single entry to our system, which allows a browser,
mobile app, or other user interface to consume services from multiple
hosts without managing cross-origin resource sharing (CORS) and
authentication for each one. We can integrate Zuul with other
Netflix projects like Hystrix for fault tolerance and Eureka for
service discovery, or use it to manage routing rules, filters, and load
balancing across your system.
Spring Cloud- Netflix Zuul Example
Q: In which business scenario to use Netflix Hystrix ?
A: Hystrix is a latency and fault tolerance library designed to
isolate points of access to remote systems, services and
3rd party libraries, stop cascading failure and enable
resilience in complex distributed systems where failure is inevitable.
Usually for systems developed using Microservices architecture, there are
many microservices involved. These microservices collaborate with each other.
Consider the following microservices-
Suppose if the microservice 9 in the above diagram failed, then using the traditional approach we will propagate an exception.
But this will still cause the whole system to crash anyways.
This problem gets more complex as the number of microservices increase.
The number of microservices can be as high as 1000.
This is where hystrix comes into picture-
We will be using two features of Hystrix-
Spring Cloud- Netflix Eureka + Ribbon + Hystrix Simple Example
Q: What is Spring Cloud Gateway? What are its advantages over Netflix Zuul?
- Fallback method
- Circuit Breaker
A: Zuul is a blocking API.
A blocking gateway api makes use of as many threads as the number of incoming requests. So this approach is
more resource intensive. If no threads are available to process incoming request then the request has to wait in queue.
In this tutorial we will be implementing API Gateway using Spring Cloud Gateway. Spring Cloud Gateway is
a non blocking API.
When using non blocking API, a thread is always available to process the incoming request. These
request are then processed asynchronously in the background and once completed the response is returned. So no incoming
request never gets blocked when using Spring Cloud Gateway.
Spring Cloud Gateway Tutorial - Hello World Example
Q: What is Spring Cloud Bus? Need for it?
Consider the scenario that we have multiple applications reading the properties using the Spring Cloud Config and the Spring Cloud Config in turn reads these
properties from GIT.
Consider the below example where multiple employee producer modules are getting the property for Eureka Registration from Employee Config Module.
What will happen if suppose the eureka registration property in GIT changes to point to another Eureka server. In such a scenario we will have to restart the services
to get the updated properties. There is another way of using Actuator Endpoint /refresh
. But we will have to individually call this url
for each of the modules. For example
if Employee Producer1 is deployed on port 8080 then call
. Similarly for Employee Producer2 http://localhost:8081/refresh
and so on.
This is again cumbersome. This is where Spring Cloud Bus comes into picture.
The Spring Cloud Bus provides feature to refresh configurations across multiple
instances. So in above example if we refresh for Employee Producer1, then it will automatically refresh for all other required modules.
This is particularly useful if we are having multiple microservice up and running. This is achieved by connecting all microservices to a single message broker. Whenever
an instance is refreshed, this event is subscribed to all the microservices listening to this broker and they also get refreshed. The refresh to any single instance can
be made by using the endpoint /bus/refresh
Spring Cloud Tutorial - Publish Events Using Spring Cloud Bus
Q: What is Spring Cloud Data Flow? Need for it?
Spring Cloud Data Flow is a toolkit to build real-time data integration and data processing pipelines
by establishing message flows between Spring Boot applications that could be deployed on top of different runtimes.
Long lived applications require Stream Applications while Short lived applications require Task Applications.
In this example we make use of Stream Applications. Previously we had already developed Spring Cloud Stream applications to understand the concept of
Spring Cloud Stream Source
and Spring Cloud Sink
and their benefit.
Pipelines consist of Spring Boot apps, built using the Spring Cloud Stream or Spring Cloud Task microservice frameworks.
SCDF can be accessed using the REST API exposed by it or the web UI console.
We can make use of metrics, health checks, and the remote management of each microservice application
Also we can scale stream and batch pipelines without interrupting data flows.
With SCDF we build data pipelines for use cases like data ingestion, real-time analytics, and data import and export.
SCDF is composed of the following Spring Projects-
Spring Cloud Tutorial - Stream Processing Using Spring Cloud Data Flow
Q:What is Docker? How to deploy Spring Boot Microservices to Docker?
What is Docker
Deploying Spring Based WAR Application to Docker
Deploying Spring Based JAR Application to Docker
Q: How to deploy multiple microservices to docker?
A: Deploying Multiple Spring Boot Microservices using Docker Networking
Q: What is Pivotal Cloud Foundry(PCF)?
Some time back all the IT infrastructure was on premises. There we in house servers managed by an IT resource personnel or a service provider.
Then with advent of cloud services these software and hardware services are now delivered over the internet rather than being on premises.
Cloud Foundry is an open source, multi-cloud application platform as a service governed
by the Cloud Foundry Foundation. The software was originally developed by VMware and then transferred to Pivotal Software,
a joint venture by EMC, VMware and General Electric.
It is a service (PaaS) on which developers can build, deploy, run and scale applications.
Many Organizations provide the cloud foundry platform separately. For example following are some cloud foundry providers-
Q: How to deploy Spring Boot Application to PCF?
Pivotal Cloud Foundry
HPE Helion Stackato 4.0
CenturyLink App Fog
SAP Cloud Platform
Swisscom Application Cloud
Deploying Spring Boot Application to PCF
Q: How to deploy Spring Boot + MySQL Application to PCF?
Pivotal Cloud Foundry Tutorial - Deploying Spring Boot + MySQL Application to PCF
Q: How to deploy Spring Boot + RabbitMQ Application to PCF?
Pivotal Cloud Foundry Tutorial - Deploying Spring Boot + RabbitMQ Application to PCF
Spring Batch Interview Questions
Apache Camel Interview Questions
JBoss Fuse Interview Questions
Drools Interview Questions
Java 8 Interview Questions