KNOW Top 25+ Microservices Interview Questions & Answers
Microservices Interview Questions and Answers

KNOW Top 25+ Microservices Interview Questions & Answers

Last updated on 04th Jul 2020, Blog, Interview Questions

About author

Ragavan (Sr Technical Manager )

He is Possessing 7+ Years Of Experience in Microservices. His Passion lies in Developing Entrepreneurs & Activities. Also, Rendered his intelligence to the Enthusiastic JOB Seekers.

(5.0) | 16212 Ratings 1176

Microservices – also known as the microservice architecture – is an architectural style that structures an application as a collection of services that are. Highly maintainable and testable. Loosely coupled. Independently deployable. Organized around business capabilities.

1) What Is Spring Cloud?

Ans:

Probably, the first microservices interview question that you may encounter. Spring Cloud in Microservices, is a system that provides integration with external systems. It is a short-lived framework that builds an application in a fast manner. Being associated with the finite amount of data processing, it plays a very important role in Microservice architecture.

For typical use cases, Spring cloud provides some out of the box experience and a set of extensive features mentioned-below:

  • Versioned and distributed configuration
  • Discovery of service registration
  • Service to service calls
  • Routing
  • Circuit breakers and load balancing
  • Cluster state and leadership election
  • Global locks and distributed messaging

2) What Is Spring Boot?

Ans:

With the new functionalities that have been added, Spring got more complex. Whenever you are starting a new project it is mandatory to add a new build path or Maven dependencies. In short, you will need to do everything from scratch. Spring Boot is the solution that will help you to avoid all the code configurations. Explaining by a real time example is better while answering this common microservices interview question. If you are cooking a dish, the ingredients can be considered to be Spring. While Spring Boot is the completely cooked recipe.

3) How Do You Override A Spring Boot Project’s Default Properties?

Ans:

This can be done by specifying the properties in application.properties.

  • For example – In Spring MVC applications, you have to specify the suffix and prefix. This can be done by entering the properties mentioned below in application.properties.
  • For suffix – spring.mvc.view.suffix: .jsp
  • For prefix – spring.mvc.view.prefix: /WEB-INF/

4) Role Of Actuator In Spring Boot

Ans:

It is one of the most important features, which helps you to access the current state of an application that is running in production environment. There are multiple metrics which can be used to check the current state. They also provide endpoints of restful web services which can be simply used to check the different metrics.

5) How Is Spring Security Implemented In A Spring Boot Application?

Ans:

Minimal configuration is needed for implementation. All you need to do is, add spring-boot-starter-security starter in the file pom.xml. You will also need to create a Spring config class that will override the required method while extending the WebSecurityConfigurerAdapter to achieve security in the application.

6) Which Embedded Containers Are Supported By Spring Boot?

Ans:

Whenever you are creating a Java Application, deployment can be done by 2 methods:

  • By using an application container that is external
  • You can also embed the container inside your jar file.

Spring Boot contains Jetty, Tomcat and undertow servers, all of which are embedded.

  • Jetty – Used in a wide number of projects, Eclipse Jetty can be embedded in frameworks and application servers, tools as well as clusters.
  • Tomcat – Apache Tomcat is an open source JavaServer pages implementation which works well with embedded systems.
  • Undertow – A flexible and prominent web server that uses small single handlers to develop a web server.

7) What Do You Mean By End-To-End Testing Of Microservices?

Ans:

End to End testing validates all the processes in the workflow to check if everything is working properly as expected. It also ensures that the system works in a unified manner, thereby satisfying the business requirement.

8) What Is Semantic Monitoring?

Ans:

  • It combines monitoring of the entire application along with automated tests. The primary benefit of Semantic Monitoring is to find out the factors which are more profitable to your business.
  • Semantic monitoring along with service layer monitoring approaches monitoring of microservices from a business point of view. Once an issue is detected, they allow faster isolation and bug triaging, thereby reducing the main time required to repair. It triages the service layer and transaction to figure out the transactions affected by availability or poor performance.

9) How Can You Set Up Service Discovery?

Ans:

  • There are multiple ways to set up service discovery. I’ll choose the one that I think to be most efficient, Eureka by Netflix. It is a hassle-free procedure that does not weigh much on the application. Plus, it supports numerous types of web applications.
  • Eureka configuration involves 2 steps – Client configuration and server configuration.
  • Client configuration can be done easily by using the property files. In the classpath, Eureka searches for eureka-client.properties. It also searches for overrides caused by the environment in property files that are environment-specific.
  • For server configuration, you have to configure the client first. Once that is done, the server fires up a client which is used to find other servers. The Eureka server, by default, uses the Client configuration to find the peer server.

10) Why Would You Opt For Microservices Architecture?

Ans:

A very common microservices interview question which you should be ready for! There are plenty of pros that are offered by Microservices architecture. Here are a few of them:

  • Microservices can adapt easily to other frameworks or technologies.
  • Failure of a single process does not affect the entire system.
  • Provides support to big enterprises as well as small teams.
  • Can be deployed independently and in relatively less time.

11) Why Would You Need Reports & Dashboards In Microservices?

Ans:

Reports and dashboards are mainly used to monitor and upkeep microservices. There are multiple tools that help to serve this purpose. Reports and dashboards can be used to:

  • find out which microservices expose what resources.
  • find out the services which are impacted whenever changes in a component occur.
  • provide an easy point which can be accessed whenever documentation is required.
  • Versions of the components which are deployed.
  • To obtain a sense of maturity and compliance from the components.

12) Why Do People Hesitate In Using Microservices?

Ans:

I have seen many of us fumble over this question. After all, we are appearing for microservices interview question to be hired as a Microservices architect, so acknowledging cons could always be a little tricky. Here is the answer:

  • Requires heavy investment – Microservices demand a great deal of collaboration. Since your teams are working independently, they should be able to synchronize well at all times.
  • Heavy architecture set up – The system is distributed, the architecture is heavily involved.
  • Excessive planning for handling operations overhead – You need to be ready for operations overhead if you are planning to use Microservices architecture.
  • Autonomous staff selection – Skilled professionals are needed who can support microservices that are distributed heterogeneously.

13) How Does PACT Work?

Ans:

  • PACT is an open source tool. It helps in testing the interactions between consumers and service providers. However, it is not included in the contract, increasing the reliability of the application.
  • The consumer service developer starts by writing a test which defines a mode of interaction with the service provider. The test includes the provider’s state, the request body and the response that is expected. Based on it, PACT creates a stub against which the test is executed. The output is stored in a JSON file.

14) Define Domain Driven Design

Ans:

The main focus is on the core domain logic. Complex designs are detected based on the domain’s model. Involves collaboration with domain experts constantly to resolve issues related to the domain and improve the model of the application. While answering this microservices interview question, you will also need to mention the core fundamentals of DDD. They are

  • DDD focuses mostly on domain logic and the domain itself.
  • Complex designs are completely based on the domain’s model.
  • To improve the design of the model and fix any emerging issues, DDD constantly works in collaboration with domain experts.

15) What is Coupling and Cohesion?

Ans:

  • The coupling can be considered to be the measurement of strength between the dependencies of a component. A good Microservices application design always consists of low coupling and high cohesion.
  • Following the previous question, often the interviewer will ask about cohesion. It is also another measurement unit. More like a degree to which the elements inside a module remain bonded together.
  • If you are appearing for microservices interview questions then it is imperative to keep in mind that an important key to design microservices is a composition of low coupling along with high cohesion. When loosely coupled, a service knows very little about other. This keeps the services intact. In high cohesion, it becomes possible to keep all the related logic in a service. Otherwise, the services will try to communicate with each other, impacting the overall performance.

16) What do you know about Microservices?

Ans:

  • Microservices, aka Microservice Architecture, is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.
  • In layman terms, you must have seen how bees build their honeycomb by aligning hexagonal wax cells.
  • They initially start with a small section using various materials and continue to build a large beehive out of it.
  • These cells form a pattern resulting in a strong structure which holds together a particular section of the beehive.
  • Here, each cell is independent of the other but it is also correlated with the other cells.
  • This means that damage to one cell does not damage the other cells, so, bees can reconstruct these cells without impacting the complete beehive.

17) What is Ubiquitous language?

Ans:

  • If you have to define the Ubiquitous Language (UL), then it is a common language used by developers and users of a specific domain through which the domain can be explained easily.
  • The ubiquitous language has to be crystal clear so that it brings all the team members on the same page and also translates in such a way that a machine can understand.

18)  What is Cohesion?

Ans:

The degree to which the elements inside a module belong together is said to be cohesion.

19) What is Coupling?

Ans:

The measure of the strength of the dependencies between components is said to be coupling. A good design is always said to have High Cohesion and Low Coupling.

20) What is REST/RESTful and what are its uses?

Ans:

  • Representational State Transfer (REST)/RESTful web services are an architectural style to help computer systems communicate over the internet. This makes microservices easier to understand and implement.
  • Microservices can be implemented with or without RESTful APIs, but it’s always easier to build loosely coupled microservices using RESTful APIs.

    Subscribe For Free Demo

    21) What do you know about Spring Boot?

    Ans:

    It’s a knows fact that spring has become more and more complex as new functionalities have been added. If you have to start a new spring project, then you have to add build path or add maven dependencies, configure application server, add spring configuration. So everything has to be done from scratch.

    22) What is an actuator in Spring boot?

    Ans:

    Spring Boot actuator provides restful web services to access the current state of running an application in the production environment. With the help of actuator, you can check various metrics and monitor your application.

    23) Why Would You Need Reports and Dashboards in Microservices?

    Ans:

    Reports and dashboards are mainly used to monitor and upkeep microservices. There are multiple tools that help to serve this purpose. Reports and dashboards can be used to:

    • Find out which microservices expose what resources.
    • Find out the services which are impacted whenever changes in a component occur.
    • Provide an easy point which can be accessed whenever documentation is required.
    • Versions of the components which are deployed.
    • To obtain a sense of maturity and compliance from the components.

    24) Can you give a gist about Rest and Microservices?

    Ans:

    Though you can implement microservices in multiple ways, REST over HTTP is a way to implement Microservices. REST is also used in other applications such as web apps, API design, and MVC applications to serve business data.

    Microservices

    • Microservices is an architecture wherein all the components of the system are put into individual components, which can be built, deployed, and scaled individually. There are certain principles and best practices of Microservices that help in building a resilient application.
    • In a nutshell, you can say that REST is a medium to build Microservices.

    25) What are different types of Tests for Microservices?

    Ans:

    While working with microservices, testing becomes quite complex as there are multiple microservices working together. So, tests are divided into different levels.

    • At the bottom level, we have technology-facing tests like- unit tests and performance tests. These are completely automated.
    • At the middle level, we have tests for exploratory testing like the stress tests and usability tests.
    • At the top level, we have acceptance tests that are few in number. These acceptance tests help stakeholders in understanding and verifying software features.

    26) What do you understand by Distributed Transaction?

    Ans:

    Distributed Transaction is any situation where a single event results in the mutation of two or more separate sources of data which cannot be committed atomically. In the world of microservices, it becomes even more complex as each service is a unit of work and most of the time multiple services have to work together to make a business successful.

    27) What is an Idempotence and where it is used?

    Ans:

    • Idempotence is the property of being able to do something twice in such a way that the end result will remain the same i.e. as if it had been done once only.
    • Usage: 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.

    28) What is Bounded Context?

    Ans:

    Bounded Context is a central pattern in Domain-Driven Design. It is the focus of DDD’s strategic design section which is all about dealing with large models and teams. DDD deals with large models by dividing them into different Bounded Contexts and being explicit about their inter-relationships.

    29) What are Client certificates?

    Ans:

    A type of digital certificate that is used by client systems to make authenticated requests to a remote server is known as the client certificate. Client certificates play a very important role in many mutual authentication designs, providing strong assurances of a requester’s identity.

    30) What is OAuth?

    Ans:

    OAuth stands for open authorization protocol. This allows accessing the resources of the resource owner by enabling the client applications on HTTP services such as third-party providers Facebook, GitHub, etc. So with this, you can share resources stored on one site with another site without using their credentials.

    Course Curriculum

    Best Industry Curated Microservices Certification Course By Expert Trainers

    Weekday / Weekend BatchesSee Batch Details

    31) What do you understand by Contract Testing?

    Ans:

    According to Martin Flower, contract test is a test at the boundary of an external service which verifies that it meets the contract expected by a consuming service.Also, contract testing does not test the behavior of the service in depth. Rather, it tests that the inputs & outputs of service calls contain required attributes and the response latency, throughput is within allowed limits.

    32) What is End to End Microservices Testing?

    Ans:

    • End-to-end testing validates each and every process in the workflow is functioning properly. This ensures that the system works together as a whole and satisfies all requirements.
    • In layman terms, you can say that end to end testing is a kind of tests where everything is tested after a particular period.

    33) What is DRY in Microservices architecture?

    Ans:

    DRY stands for Don’t Repeat Yourself. It basically promotes the concept of reusing the code. This results in developing and sharing the libraries which in turn result in tight coupling.

    34) What is a Consumer-Driven Contract (CDC)?

    Ans:

    • This is basically a pattern for developing Microservices so that they can be used by external systems. When we work on microservices, there is a particular provider who builds it and there are one or more consumers who use Microservice.
    • Generally, providers specify the interfaces in an XML document. But in Consumer Driven Contract, each consumer of service conveys the interface expected from the Provider.

    35) What is the role of Web, RESTful APIs in Microservices?

    Ans:

    A microservice architecture is based on a concept wherein all its services should be able to interact with each other to build a business functionality. So, to achieve this, each microservice must have an interface. This makes the web API a very important enabler of microservices. Being based on the open networking principles of the Web, RESTful APIs provide the most logical model for building interfaces between the various components of a microservice architecture.

    36) What do you understand by Semantic monitoring in Microservices architecture?

    Ans:

    Semantic monitoring, also known as synthetic monitoring combines automated tests with monitoring the application in order to detect business failing factors.

    37)  How can we perform Cross-Functional testing?

    Ans:

    Cross-functional testing is a verification of non-functional requirements, i.e. those requirements which cannot be implemented like a normal feature.

    38) What is Continuous Monitoring?

    Ans:

    Continuous monitoring gets into the depth of monitoring coverage, from in-browser front-end performance metrics, through application performance, and down to host virtualized infrastructure metrics.

    39) What is the role of an architect in Microservices architecture?

    Ans:

    An architect in microservices architecture plays the following roles:

    • Decides broad strokes about the layout of the overall software system.
    • Helps in deciding the zoning of the components. So, they make sure components are mutually cohesive, but not tightly coupled.
    • Code with developers and learn the challenges faced in day-to-day life.
    • Make recommendations for certain tools and technologies to the team developing microservices.
    • Provide technical governance so that the teams in their technical development follow principles of Microservice.

    40) What are the uses of Reports and Dashboards in Microservices environments?

    Ans:

    Reports and Dashboards are generally used to monitor a system. For microservices Reports and Dashboards help to:

    • Find which microservice support which resource.
    • Find out the services that are impacted whenever changes in components are made/occur.
    • Provide an easy point of access for documentation purposes.
    • Review versions of the deployed components.
    • Obtain compliance from the components.

    41) What do you understand by Idempotence, and how is it used?

    Ans:

    Idempotence refers to the repeated performing of a task even though the end result remains the same. It is used mostly as a data source or a remote service in a way that when it receives the instruction more than once, it processes the instruction only once. 

    42) How do you perform security testing of Microservices?

    Ans:

    Microservices Application is a collection of smaller, independent, functional modules that may be developed in different programming languages, have different data sources, and run on different operating systems. This makes testing of the microservices as a whole a very tough task. The different pieces/modules need to be tested independently. There are three common procedures for this.

    • Code Scanning: In order to ensure that every line of code is bug-free and can be replicated.
    • Flexibility: The security protocols should be flexible as per the requirements of the system.
    • Adaptability: The security protocols should be adaptable to the malicious intrusions.

    43) Why Do People Hesitate to Use Microservices?

    Ans:

    I have seen many devs fumble over this question. After all, they’re getting asked this question when interviewing for a microservices architect role, so acknowledging its cons can be a little tricky. Here are some good answers:

    • They require heavy investment – Microservices demand a great deal of collaboration. Since your teams are working independently, they should be able to synchronize well at all times.
    • They need heavy architecture set up – The system is distributed, the architecture is heavily involved.
    • They need excessive planning for handling operations overhead – You need to be ready for operations overhead if you are planning to use a microservices architecture.
    • They have autonomous staff selection – Skilled professionals are needed who can support microservices that are distributed heterogeneously.

    44) How do independent Microservices communicate with each other?

    Ans:

    Microservices can communicate with each other through:

    • HTTP for traditional Request-Response.
    • Websockets for streaming.
    • Brokers or Server Programs running Advanced Routing Algorithms.

    For message brokers, RabbitMQ, Nats, Kafka, etc., can be used, each built for a particular message semantic. Another way is to use Backend As A Service like Space Cloud, which automates the entire backend. 

    45) How can you access RESTful Microservices?

    Ans:

    Considering the microservice architecture concept, each microservice needs to have an interface. Based on the principles of open networking of the Web, RESTful APIs provide the most logical model for building interfaces between the various components of the microservices architecture. RESTful APIs can be accessed in two ways:

    • Using a REST Template that is load balanced.
    • I am using multiple microservices.

    46) How will you deploy Exception Handling in Microservices?

    Ans:

    If an exception occurs while processing an HTTP request, you need to catch the exception in your controller or service and return an appropriate ResponseEntity manually.  Here are some thumb rules for exception handling.

    • Add @ResponseStatus for exceptions that you write.
    • For all other exceptions, implement an @ExceptionHandler method on a @ControllerAdvice class or use an instance of SimpleMappingExceptionResolver. 
    • For Controller specific exceptions, add @ExceptionHandler methods to your controller. 

    47) What is Spring Batch Framework?

    Ans:

    Spring Batch is an open-source framework for batch processing – execution of a series of jobs. Spring Batch provides classes and APIs to read/write resources, transaction management, job processing statistics, job restart, and partitioning techniques to process high volume data.

    48) When will you see fit to use the Netflix Hystrix?

    Ans:

    Hystrix is an error tolerance and latency library. Hystrix mainly isolates the access points. It also makes sure that all 3rd Party libraries and services are restricted. Thus, we can use Hystrix to ensure that an application runs efficiently and avoids the kind of failures that occur in distributed systems. 

    49) How will you balance the server-side load by utilizing Spring Cloud?

    Ans:

    The server-side load balancing can be done by using Netflix Zuul. It is also known as a JVM based router.

    50) What is Eureka in Microservices?

    Ans:

    Eureka is alternatively known as the Netflix Service Discovery Server. It uses Spring Cloud and is not heavy on the application development process.

    Course Curriculum

    Get Hands-on Practical Microservices Training with Instructor-led Classes

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

    51) What is the role of RESTful APIs in Microservices?

    Ans:

      A microservice is based on the concept where all it’s component services require to interact with one another to complete the business functionality. This requires each microservice to have an interface. RESTful APIs provide a logical model for building these interfaces. It is based on the open networking principles of the Web. Thus, it serves as the most critical enabler of microservices. 

    52) What are Reactive Extensions in Microservices?

    Ans:

    Reactive Extensions is a design approach through which results are collected by calling multiple services in order to compile a combined response. Also known as Rx, these calls can be synchronous or asynchronous.

    53) What are non-deterministic tests, and how will you eliminate them?

    Ans:

    NDT or Non-Deterministic are unreliable tests. Such tests sometimes pass and sometimes fail. When these tests fail, they are re-run to give. Non-Determinism from tests can be eliminated in the following ways:

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

    54) How does a Microservice Architecture work?

    Ans:

      Under a microservice architecture, an application is simplified into multiple modules that independently perform the single precise standalone task:

    • Are fragmented into loosely coupled various modules, each of which performs a distinct function.
    • It can be or are distributed across clouds and data centers.
    • Implement each module as an independent service/process which can be replaced, updated, or deleted without disrupting the rest of the application.

    Under microservice architecture, an application can grow along with its requirements. 

    55) What are the fundamental characteristics of a Microservices Design?

    Ans:

    • Services split up and organized around business functionality.
    • Separate modules handled and owned by different development teams.
    • Decentralized Framework.
    • Maintenance of respective modules by respective development teams.
    • Separate modules may be maintained by different databases.
    • Modules in a Microservice Architecture are separately deployable. They can be updated, enhanced, or deleted without disrupting the entire architecture.
    • Real-time monitoring of the application.

    56) What are the main challenges in Microservice Deployment?

    Ans:

    The challenges in Microservice can be both technical as well as functional. 

    1. From the point of business, the main challenges are:
    • Require heavy investment
    • Heavy Infrastructure Setup
    • Excessive Planning for managing operations overhead
    • Staff Selection and maintenance.
    1. From a technical standpoint – 
    • Communication between different microservices in the application.
    • Component automation
    • Application maintenance
    • Configuration Management
    • Heavy Operations Overhead
    • Deployment Challenges
    • Testing and Debugging Challenges

    57) What are the different strategies of Microservices Deployment?

    Ans:

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

    58) What is Domain Driven Design?

    Ans:

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

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

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

    Ans:

    It depends upon your project needs. However, in most cases, developers use HTTP/REST with JSON or Binary protocol. However, they can use any communication protocol.

    60) What is the use of Docker?

    Ans:

    Docker offers a container environment which can be used to host any application. This software application and the dependencies that support it which are tightly-packaged together.

    Microservices Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    61) What is a CDC?

    Ans:

    CDC is Consumer-Driven Contract. It is a pattern for developing Microservices so that external systems can use them.

    62) What is the meaning of Semantic monitoring in Microservices architecture?

    Ans:

    Semantic monitoring combines automated tests with monitoring of the application. It allows you to find out reasons why your business is not getting more profits.

    63) Why are Container used in Microservices?

    Ans:

    Containers are easiest and effective method to manage the microservice based application. It also helps you to develop and deploy individually. Docker also allows you to encapsulate your microservice in a container image along with its dependencies. Microservice can use these elements without additional efforts.

    64) What is the meaning of OAuth?

    Ans:

    OAuth means open authorization protocol. This protocol allows you to access the client applications on HTTP for third-party providers GitHub, Facebook, etc. It helps you to share resources stored on one site with another site without the need for their credentials.

    65) Explain the use of PACT in Microservices architecture?

    Ans:

    It is an open source tool which allows testing interactions between service providers and consumers. However, it is separated from the contract made. This increases the reliability of the Microservices applications.

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free