1.    What is Spring Boot?

To start a new Spring project one has to add the maven dependencies or the build path, add configurations, configure the application server, etc. Therefore, it requires some efforts from the developer before actually starting the project from scratch. Here, Spring Boot comes into action and provides automation for these tasks.

Spring Boot is a part of Spring module present in the Spring framework. It provides an easy way for creating stand-alone applications with zero configurations. It will automatically perform all the configurations and at the same time allows to override the default configurations, if needed.

Spring Boot is created on top of existing Spring framework and minimizes the efforts required for all the configurations to be done before. Thus it helps in using the Spring functionalities in a much better way and with minimum efforts.

2.    What are Microservices?

To understand the concept of Microservices, first we need to understand what are monolithic applications and the problems with them.

Monolithic applications: All the applications where all business rules are on the same code base are called Monolithic Applications 

Understanding the problem with monolithic applications:

  • Maintenance on the same code base is sometimes difficult due to code merging
  • Deployment of new features without impacting the one which already exists in the production is difficult
  • Implementation of new features is complex in monolithic applications as it may affect the previously existing code
  • If you need changes in the architecture of the application, it becomes very complex

Because of all these difficulties, we can migrate to Microservices.


Microservices is basically an architectural style to work with the systems where scale is a factor. Microservices are used to solve the problems of the systems that are too big. There are systems that grow in size beyond the boundaries that designers initially design and when there is a need to make some changes then it becomes a problem.

  • Small: Microservices are small, autonomous services that work together. They are focused on doing one thing well.
  • Single purpose: This is where the simplicity comes in. One microservice does one very small thing, could be as small as a function.
  • Autonomous: Our microservice is a separate entity. It might be deployed as an isolated service.

3.   What are the benefits of using Microservices?

Benefits of using Microservices are:

1. Scaling:

  • Scale up a specific service that is being used more.
  • For e.g. There is a product look up service and a product buy service.
  • There are people on internet who surf on the internet more for various thing things rather than buying the products.
  • So, product look up service is very high in demand whereas a product buy service is not that much needed. We can run product look up service on a powerful hardware having multiple servers and product buy service can be on a hardware which is less powerful.

2. Technology Heterogeneity:

  • As microservices system is a combination of multiple services, it provides the freedom to choose different technologies in any of its services. Therefore, we can easily choose the appropriate toll for every single job.

3. Resilience:

  • If one service goes down, then rest of the services should not be affected and they should keep running.
  • The service causing the problem can be isolated easily and the remaining services in the system will be working without any impact.
  • It helps in building systems which are capable of handling the complete failure of services also and then degrading the required functionality accordingly.

4. Ease of deployment:

  • Even a single line of change in a monolithic application needs the complete application’s redeployment so that the changes reflect in the production.
  • But with Microservices it is very simple to perform changes in an individual service and then independently deploy it in the system.
  • This helps in deploying the code faster and even if there is some problem, it can be easily isolated, thus making the rollback faster.

4.    What is a Microservices architecture?

A Microservices architecture is an architecture that structures a software project in a set of services that are low-coupled and that can be developed in a collaborative way. Each service will take care of a precise function and the limits that exist between two different tasks will be correctly and firmly separated.

In general, in monolithic applications, a component or library, at the time of execution, is appropriately linked to the rest of the project in order to be usable within the executive stream. We therefore see the feature that is always satisfied to store the code of the library within the code developed by us. On the contrary, in the case of microservice architecture, libraries are not software artifacts to be imported and linked to our sources, but real Microservices performed autonomously and independently of each other.

In both cases there is a dependency between the code of the main application and the libraries’ one; but, in the first case, the dependency takes place through an exchange of data in memory, while in the second case the whole is expressed through an exchange of messages via the network between the Microservices. It is therefore clear that, unlike a monolithic architecture, in a Microservices architecture a malfunction of a single service does not compromise the operation of the whole application and the adjustment of one of them does not necessarily imply the complete recompilation.

5.    What is Spring Cloud?

Spring Cloud is a building block for Microservices and Cloud. It helps in quickly building the applications which performs a certain amount of data processing. It provides the use of services like Configuration server & monitoring. It also supports Service Discovery and helps in client side load balancing.

6.    What is Load Balancing?

Load balancing describes the process of distributing computing workloads across many different resources. A single computer to a computer cluster and across network links, different processing units (CPUs) and disk drives, load balancing strives to organize and use each resource to its capacity without overloading any singular resource. By using a network of resources, with load balancing, instead of a single computer or individual unit the resources are optimized to maximize the function and speed of the unit and minimize the response time of all the components. Dedicated hardware and/or software are usually required for load balancing. Multilayer switches or a DNS server process are regularly used for load balancing.

Netflix Ribbon is used in Spring Cloud to implement load balancing.

7.    How server-side load balancing is achieved in Spring Cloud?

Using Netflix Zuul we can achieve server side load balancing. Netflix produced Zuul, which is a JVM based server and router – side load balance tool. Zuul provides a single point of entry into the system, allowing a browser or a mobile app or other user interface to utilize services from more than one host without having to manage cross-origin resource sharing (CORS), and without having to authenticate each one. Zuul can work within other projects by Netflix such as Hystrix, which is used for fault tolerance. Eureka is a service discovery tool which can manage routing rules and filters and includes the load balancing across the system.

8.    Explain the Microservices Discovering and Registration.

In general, in any cloud environment there are file structure. So what ever the services that are been deployed are deployed in a server which acts as a phone book containing all the information about services such as port, host name. We need some mechanism to call services instances and to reuse it. Spring Cloud provides automatic registration and discovering features named as Eureka. Now let us discuss some of the core component provided by Spring cloud. Eureka servers are the servers which have the information of micro services such as port, host name, serviceId etc. It is also known as Discovery Server.

Now in the above image there are 3 incoming request which calls the rest endpoints of the service that is been deployed in the Discovery Server.

Now when the service is started it needs some configuration parameter and that is stored within a server named as Config Server.

So let’s see the step by step implementation of it.

Step 1:  Create Eureka Server or Discovery Server

Add following dependency to pom.xml and use the concept of sts.




import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
public class EurekaServer {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServer.class, args);

Step 2: Now in application.properties file for automatic registration of service to server just add the configuration
Step 3: Now let us create EurekaClient i.e. microservice


In application.properties file add this configuration

9. What is Eureka? How to register with eureka?

A REST (Representational State Transfer) based micro service which is used to locate services for the purpose of load balancing and to isolate failover of middle-tier servers majorly used in Amazon web services.
spring-cloud-starter-netflix-eureka-client on the classpath, application automatically registers with the Eureka Server. Example configuration to locate eureka server (application.yml should have entries like below) for an existing spring boot application.

      defaultZone: http://localhost:7777/eureka/


10. In which business scenario to use Netflix Hystrix?

Netflix Hystrix is a design and implementation of circuit breaker pattern to isolate failure points and stop cascading them. It uses circuit breaker and fall back mechanisms to detect failures. This can be done with annotation @HystrixCommand where classes are annotated with @Component or @Sevice.
When we use @HystrixCommand, Hystrix monitors failures till threshold point then subsequent calls are failed and redirected to fallback method.

class BookService{
@HystrixCommand(fallbackMethod = "reliable")
  	public String readingList() {
    	URI uri = URI.create("http://localhost:8090/recommended");
    return this.restTemplate.getForObject(uri, String.class);

  	public String reliable() {
    	return "Cloud Native Java (O'Reilly)";

In above example, Hystrix monitors readingList() method calls for failures. Once threshold is reached, Hystrix fails calls to readingList() and call reliable() method.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.