Javatpoint Logo
Javatpoint Logo

Most Asked Microservices Interview Questions

Following is the list of most frequently asked Microservices Interview questions and their best possible answers.

1) What are Microservices? / What do you understand by Microservices?

Microservices are an architectural approach or style that is used to build applications. The microservice architecture provides a rapid, frequent and reliable delivery of large and complex applications. It is distributed and loosely coupled, so it won't break the entire app if you make changes in one team.

Microservices are also known as the microservice architecture, a variant of the service-oriented architecture (SOA) structural style and used to structure an application as a collection of services that have the following features:

  • Distributed and loosely coupled
  • Highly maintainable and testable
  • Independently deployable
  • Organized around business capabilities
  • Owned by a small team

2) What are the most significant benefits of using microservices?

The most significant benefit of using microservices is that it builds an application to collect small autonomous services developed for a business domain. So, if the business needs to change constantly, the development teams can rapidly build new apps components to meet the requirement.

Each microservice runs a unique process and communicates through a well-defined, lightweight mechanism, such as a container, to serve a business goal. It also makes an organization capable of evolving its technology stack.


3) What are the three commonly used tools for Microservices?

Following are the three commonly used tools for Microservices:

  • Wiremock
  • Docker
  • Hysrix

4) What are the main components of Microservices?

Following is the list of main components of Microservices or Microservice architecture:

  • Containers, Clustering, and Orchestration
  • IaC (Infrastructure as Code Conception)
  • Cloud Infrastructure
  • API Gateway
  • Enterprise Service Bus
  • Service Delivery

5) How does a Microservice architecture work?

The Microservice architecture of an application can be simplified into multiple modules that independently perform the single precise standalone task. Let's see how Microservice architecture works:

  • An application is fragmented into loosely coupled various modules, each of which performs a distinct function.
  • It is distributed across clouds and data centers.
  • Each application module is an independent service/process that can be replaced, updated, or deleted without disrupting the rest of the application.
  • Under microservice architecture, an application can grow along with its requirements.

6) What are the main advantages of using Microservices?

Following is a list of some most important advantages of using Microservices:

  • Microservices provide great technology diversity. You can mix it easily with other frameworks, libraries, and databases.
  • Microservices support fault isolation as it collects small autonomous services or processes, so a process failure should not bring the whole system down.
  • It provides excellent support for the minor and parallel team.
  • It reduces the deployment time significantly.
  • Independent deployment

7) What do you understand by Monolithic Architecture?

Monolithic architecture is like a big container that contains all the software components of an application. These applications are clubbed inside a single package within the application.


8) What are the biggest challenges in Microservice deployment?

We can specify the biggest challenges in Microservice deployment in two ways, i.e., technical and functional.

The main challenges from the business point of view:

  • Microservices require a heavy investment.
  • It requires a heavy infrastructure setup also.
  • We need excessive planning for managing operations overhead.
  • It cost a lot in staff selection and maintenance.

The main challenges from a technical point of view:

  • The components in microservices always rely on each other, so; it requires communication between them in the application.
  • There are also a lot of challenges in deployment.
  • Testing and Debugging are very challenging.
  • It requires complete component automation and application maintenance.
  • It receives heavy operations overhead.
  • It requires skilled professionals to support heterogeneously distributed microservices.

9) What do you understand by Spring Cloud?

Spring cloud is an Integration software used to integrate with external systems. It allows a microservices framework to build applications that perform restricted amounts of data processing.


10) What are the main differences between Microservices and Monolithic Architecture?

The main differences between Microservices and Monolithic Architecture:

Microservices Monolithic Architecture
The service startup is fast in Microservices. The service startup takes time as it is slow in Monolithic Architecture.
It is a loosely coupled architecture. It is primarily a tightly coupled architecture.
In Microservices, if you make changes in a single data model, it does not affect others. In Monolithic Architecture, any changes in the data model affect the entire database.
It mainly focuses on products, not projects. It mainly focuses on the whole project.

11) In which cases microservice architecture is best suited?

The microservice architecture is best suited for all tech devices such as desktop, web, mobile devices, Smart TVs, Wearable devices, etc.


12) What are the most significant advantages and disadvantages of using Microservices?

Following is the list of the most significant advantages and disadvantages of using Microservices:

Advantages of Microservices

  • Provide improved scalability
  • Increased Agility
  • Localized Complexity
  • Provide fault isolation
  • Debugging & Maintenance are easy and simplified.
  • Communication between developers with business users is accessible and better.
  • Smaller development teams
  • You can easily upgrade the technology.

Disadvantages of Microservices

  • As a whole project, it isn't easy because it uses multiple components in the application.
  • It requires accurate pre-planning before use.
  • It uses modular dependencies that are hard to calculate.
  • The third-party applications are hard to control.
  • Modular interdependencies are challenging to track.
  • More opportunities for malicious intrusions.
  • Complete end-to-end testing is complex.
  • Deployment Challenges.

13) Which are some famous companies that are using Microservice architecture?

Most large-scale software companies and websites such as Twitter, Netflix, Amazon are using microservices architecture instead of monolithic architecture.


14) What do you understand by RESTful?

REST or RESTful stands for Representational State Transfer. The RESTful web service is an architectural style that helps computer systems to communicate over the internet. These web services make microservices easier to understand and implement.


15) What are the different strategies used in Microservices deployment?

Following strategies are used in Microservices deployment:

  • Multiple Service Instance per Host: It is used to run single or multiple service instances of the application on a single or multiple physical/virtual hosts.
  • Service Instance per Host: It is used to run a service instance per host.
  • Service Instance per Container: It is used to run each service instance in its respective container.
  • Serverless Deployment: It packages the service as a ZIP file and uploads it to the Lambda function. The Lambda function is a stateless service that automatically runs enough micro-services to handle all requests.

16) What are the three types of tests used in Microservices?

We can categorize the tests used in Microservice architecture into three main categories:

  • Bottom Level Test: The bottom-level tests perform general tests such as performance tests and unit tests. These kinds of tests are entirely automated.
  • Middle-Level Tests: The middle-level tests are used to perform exploratory tests such as the stress test and usability test.
  • Top Level Tests: The top-level tests are used to conduct acceptance tests, mostly fewer in numbers. These types of tests make stakeholders know about different software features.

17) What is the main difference between SOA and the Microservices Architecture?

SOA stands for Service Oriented Architecture. It is a collection of services used to communicate with each other through simple data passing or activity coordination. On the other hand, the Microservices Architecture is a collection of small functional modules that are independently deployable, scalable, target specific business goals, and communicate over standard protocols.


18) What is a Client certificate? What is its usage?

A client certificate is a digital certificate used to make authenticated requests to a remote server. A certificate is generated for each microservice.


19) What do you understand by Domain-Driven Design?

Domain-Driven Design is an architectural style based on Object-Oriented Analysis Design concepts and principles. It is used to develop a complex system by connecting the related components of the software system into a continuously evolving system. Domain-Driven Design is based on three principles:

  • Focus on the core domain and domain logic.
  • Base complex designs on models of the domain.
  • Collaborate with the domain experts to improve the application model and resolve any emerging domain-related issues regularly.

20) What is the use of PACT in Microservices architecture?

PACT is an open-source tool used for testing interactions between service providers and consumers. It increases the reliability of the Microservices applications.


21) What do you understand by OAuth?

OAuth stands for Open Authorization protocol. This protocol allows you to access the client applications on HTTP for third-party providers GitHub, Facebook, etc. It also facilitates us to share resources stored on one site with another site without their credentials.


22) What is Spring Boot? Why is it used?

Spring Boot is an open-source, Java-based framework that provides developers an excellent platform for developing a stand-alone and production-grade spring application. It is easy to understand, reduces development time, and increases productivity. It automatically configures a claim based on the added dependencies of an application.


23) What is the method to override a Spring Boot project's default properties?

We can do it by specifying the properties in application.properties. The Spring MVC applications need the suffix and the prefix to be specified. This can be done by:

  • For suffix:mvc.view.suffix: .jsp
  • For prefix:mvc.view.prefix: /WEB-INF/

24) What do you understand by end-to-end Microservices testing?

End-to-end testing is used to validate that every process in the workflow is functioning correctly. It also ensures that the system works together as a whole and fulfills all the requirements.


25) What is the difference between Coupling and Cohesion?

Difference between Coupling and Cohesion

Coupling: Coupling is specified as a relationship between module A and another module B. There are mainly three types of coupling. Any module can be highly coupled (highly dependent), loosely coupled, and uncoupled with other modules. The best coupling is the loose coupling which can be achieved through interfaces.

Cohesion: Cohesion is the relationship between 2 or more parts within a module. The high cohesion within a module specifies that the module can perform a specific task with maximum efficiency on its own, without the need to communicate with other modules. High cohesion increases the functional strength of the module.

microservices Interview Questions

26) What is the use of containers in Microservices?

Containers are the easiest and effective method to manage microservice-based applications. They are like a software development platform. They also help us to develop and deploy individually. A Docker is an example of a container. It is an open-source software development platform that allows us to encapsulate our microservice in a container image along with its dependencies. Microservice can use these elements without additional efforts.


27) What is Spring Cloud? What problems can be solved by using Spring Cloud?

Spring Cloud is a collection of tools used by developers to quickly build some of the common patterns in distributed systems such as configuration management, circuit breakers, service discovery, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state, etc.

We can use spring cloud to solve the following problems:

  • We can solve network issues, latency overhead, bandwidth issues, security issues, and other issues occurred in distributed systems.
  • We can also solve redundancy issues that occur in distributed systems.
  • We can balance the distribution of load between resources like network links, CPU, clusters, etc.
  • We can solve the performance issues that occurred because of operational overheads.
  • We can resolve the service discovery issues to make smooth communication possible between services in a cluster.

28) What do you understand by semantic monitoring in Microservices architecture?

Semantic monitoring is used to combine the automated tests by monitoring the application. It is used to find out the reasons why your business is not getting more profits.


29) What do you understand by the Distributed Transaction?

A distribution transaction is a type of transaction that has two or more engaged network hosts. In this transaction, a transaction manager takes care of developing and handling transactions. If the transaction involves more than one peer, the transaction managers of each peer communicate with each other using subordinate or superior relationships. In the same way, the resource manager handles the resources and coordinates with the distributed transaction coordinator for transaction atomicity and isolation.


30) What is the full form of CDC? What is its usage?

The full form of CDC is a Consumer-Driven Contract. It is a pattern used for developing Microservices so that the external systems can use them efficiently.


31) What is Reactive Extension in Microservices?

Reactive Extension is a design pattern that allows collecting results by calling multiple services and then compiles a combined response. It is also called Rx. Rx is a popular tool in distributed systems that works opposite to legacy flows.


32) How can you configure Spring Boot application login?

We can configure the Spring Boot application login by specifying the logging.level in the application.properties file. Generally, it is pre-configured as console output.


33) What do you understand by the term 'Continuous Monitoring'?

The term continuous monitoring is used to specify a method used to search compliance and risk issues associated with a company's operational and financial environment. This method contains human processes and working systems that support efficient and actual operations.


34) What is Mike Cohn's Test Pyramid?

Mike Cohn's Test Pyramid is used to maximize automation at all levels of testing, such as unit testing, service level testing, UI testing, etc. This pyramid specifies that while unit tests are faster and more isolated, UI tests, which are at the highest level, take time and focus on integration.

microservices Interview Questions

35) How independent micro-services communicate with each other?

We can make our micro-services communicate with each other according to our project needs. In most cases, developers use HTTP/REST with JSON or Binary protocol while using any communication protocol.


36) How can you implement a Spring Security in a Spring Boot Application?

We can quickly implement a Spring Security in a Spring Boot Application by using the following method:

  • By adding the spring-boot-starter-security in the file pom.xml
  • By creating a Spring config class that will override the required method while extending the WebSecurityConfigurerAdapter to achieve security in the application

37) What do you understand by ubiquitous language?

Ubiquitous Language or UL is a common language used by developers and users of a specific domain to explain that domain easily. The ubiquitous language has to bring all the team members on the same page and be translated so that a machine can understand.


38) What is the difference between Rest and Microservices?

There are multiple ways to implement microservices. REST over HTTP is one of them. REST is also used in other applications such as web apps, API design, and MVC applications to serve business data.

On the other hand, in microservices architecture, all the system components are put into individual components, which can be built, deployed, and scaled individually. Microservices provide certain principles and best practices that help in building a resilient application. So, we can say that REST is a medium to build Microservices.


39) What do you understand by Idempotence? Where is it used?

Idempotence is a property that facilitates us to do something twice so that the result will remain the same always in such a way that if it had been done once only. Usage of Idempotence: Idempotence is used at the remote service or data source so that, when it receives the instruction more than once, it only processes the instruction once.


40) What is an Actuator in Microservices? Why is it used?

Actuator is a sub-project of Spring Boot. It brings in production-ready features into an application and is mainly used to expose operational information about the running application's health, metrics, info, dump, env, etc. It uses HTTP endpoints or JMX beans to interact with it.


41) What is the use of Bounded Context in Domain-Driven Design?

The Bounded Context is a central pattern in Domain-Driven Design. It is the core of Domain-Driven Design's strategic design section, which deals with large models and teams. It is used to divide the large models into different Bounded Contexts and being explicit about their inter-relationships.


42) What is PACT in Microservices Architecture?

The contract between a consumer application and a provider application is known as a PACT. Each PACT is a collection of interactions. It is an open-source tool that can be used to implement the Consumer-Driven Contract in Microservices.


43) What do you understand by Two Factor Authentication? What are the different types of credentials used in Two Factor Authentication?

Two-factor authentication enables the users to fulfill the second level of authentication to an account login process. If a user has to enter only a username and password at the time of login, it would be considered a single-factor authentication. But in Two-factor authentication, the user has to enter more information than the login password.

Mainly three types of credentials are used in Two-factor authentication:

  • Something you know: In this authentication step, you have to enter a PIN, password, or a pattern.
  • Something you have: This authentication step requires an ATM card, phone, or OTP.
  • Something you are: In this authentication step, you have to enter your biometric fingerprint or voice print.

44) What is the need for Reports and Dashboards in Microservices?

Reports and dashboards are mainly used to monitor microservices. There are multiple tools used for this purpose.

Following is the list of some usages of Reports and dashboards in microservices:

  • Reports and dashboards are used to find out which microservices expose what resources.
  • It is also used to specify the services which are impacted whenever we make changes in a component.
  • It provides an easy point to access whenever documentation is required.
  • It specifies the versions of the components which are deployed.
  • It is also used to obtain a sense of maturity and compliance from the components.

45) What do you understand by Canary Releasing?

Canary releasing is a technique used to introduce new software versions by rolling out the updated version or new code/features to a subset of users as an initial test before making the entire infrastructure available to everybody. This technique is called canary release because it is based on canary releases in coal mines to alert miners when the toxic gases reach dangerous levels.


46) Why do many developers hesitate in using Microservices? / What are the biggest cons of using Microservices?

There are some cons of Microservices that can make developers hesitate in using Microservices:

  • Microservices require heavy investment: It requires a great deal of collaboration. Since your teams are working independently, they should be able to synchronize well at all times.
  • The architecture setup cost is high: The Microservices system is distributed, so the architecture is heavily involved and costly.
  • Handling operations overhead is complex: Using Microservices may lead to overhead so, you need to be ready for operations overhead if you are planning to use Microservices architecture.
  • Autonomous staff selection: It requires skilled professionals to support Microservices that are distributed heterogeneously.

47) What are non-deterministic tests? What is the process to eliminate them?

Non-deterministic tests or NDT are unreliable tests that sometimes pass and sometimes fail. When these tests fail, they are re-run again. We can use the following ways to eliminate non-determinism from Non-Deterministic tests.

  • Quarantine
  • Asynchronous
  • Remote Services
  • Isolation
  • Time
  • Resource Leaks

48) What is the usage of WebMvcTest annotation in Spring MVC applications?

WebMvcTest annotation is used for unit testing in Spring MVC Applications in cases where the test objective is to focus on Spring MVC Components.

See the following code:

@WebMvcTest(value =ToTestController.class, secure = false):

Here, we want to launch only the ToTestController. All other controllers and mappings will not be launched until this unit test is executed.


49) What is Eureka in Microservices?

Eureka or Eureka Server is an application that holds the information about the client-service applications. Microservices have to register into the Eureka server, and the Eureka server knows all the client applications running on each port and IP address. Eureka Server is also alternatively known as the Netflix Service Discovery Server. It uses Spring Cloud and is not heavy on the application development process.


50) What is the full form of DRY? What is its usage in Microservices architecture?

The full form of DRY is Don't Repeat Yourself. It is used to promote the concept of reusing the code. This makes things easy in developing and sharing the libraries, which in turn result in tight coupling.


51) How can you balance the server-side load by utilizing Spring Cloud?

We can use the Netflix Zuul to balance the server-side load by utilizing Spring Cloud. It is also known as a JVM-based router.


52) What do you understand by Cross-functional testing?

Cross-functional testing is the verification of non-functional requirements, i.e., the requirements that we cannot implement like a standard feature.


53) What is the use of Netflix Hystrix?

Hystrix is an error tolerance and latency library. It is mainly used to isolate the access points. It also ensures that all 3rd party libraries and services are restricted. So, the application runs efficiently and avoids the kind of failures that occur in distributed systems.


54) What do you understand by Tasklet in Microservices?

The Tasklet is a simple interface with a method to execute. We can use it to perform single tasks like running queries, deleting files, etc. In Spring Batch, the Tasklet is an interface used to perform unique tasks like clean or set up resources before or after any step execution.