Microservices Interview Questions and Answers
Last updated on 07th Oct 2020, Blog, Interview Question
Microservices architecture is a method of developing a large-scale application in the form of discrete modules that work independently of each other but as a whole account for the entire business application under consideration. Organizations are increasingly adopting this service for developing enterprise solutions. As this operates on simple, modular services, there is now an increasing demand for cloud solutions.
Microservices deployment can be Cloud-Based or On-Premise. It’s market spans across Healthcare, Banking, Government, Manufacturing, Retail, IT & Telecommunication, Media & Entertainment, Manufacturing, etc. Its intended audience includes Investors and Consultants, System Integrators, Government Organizations, IT & Technology Solution Providers. To name a few, prominent players in this field of expertise are Cognizant, IBM, Microsoft, Salesforce, and Software AG. The microservices architecture market is expected to take a massive leap by the year 2023.
If you are looking into a career in this field and are getting yourself interview ready, here are a few quick microservices interview questions and answers you can expect.
1. What Is Spring Cloud?
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:
- 1. Versioned and distributed configuration
- 2. Discovery of service registration
- 3. Service to service calls
- 4. Routing
- 5. Circuit breakers and load balancing
- 6. Cluster state and leadership election
- 7. Global locks and distributed messaging
2. What Is Spring Boot?
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?
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
It is one of the most important features, which helps you to access the current state of an application that is running in a 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?
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?
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.
- 1. Jetty – Used in a wide number of projects, Eclipse Jetty can be embedded in frameworks and application servers, tools as well as clusters.
- 2. Tomcat – Apache Tomcat is an open source JavaServer pages implementation which works well with embedded systems.
- 3. 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?
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?
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?
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.
- 1. 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.
- 2. 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?
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?
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:
- 1. Find out which microservices expose what resources.
- 2. Find out the services which are impacted whenever changes in a component occur.
- 3. Provide an easy point which can be accessed whenever documentation is required.
- 4. Versions of the components which are deployed.
- 5. To obtain a sense of maturity and compliance from the components.
12. Why Do People Hesitate In Using Microservices?
I have seen many of us fumble over this question. After all, we are appearing for microservices interview questions to be hired as a Microservices architect, so acknowledging cons could always be a little tricky. Here is the answer:
- 1. 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.
- 2. Heavy architecture set up – The system is distributed, the architecture is heavily involved.
- 3. Excessive planning for handling operations overhead – You need to be ready for operations overhead if you are planning to use Microservices architecture.
- 4. Autonomous staff selection – Skilled professionals are needed who can support microservices that are distributed heterogeneously.
13. How Does PACT Work?
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
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?
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 others. 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.
Subscribe For Free Demo[contact-form-7 404 "Not Found"]
16. What do you know about Microservices?
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?
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?
The degree to which the elements inside a module belong together is said to be cohesion.
19. What is Coupling?
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?
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.
21. What do you know about Spring Boot?
It’s a known 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?
Spring Boot actuator provides restful web services to access the current state of running an application in the production environment. With the help of an actuator, you can check various metrics and monitor your application.
23. Explain the use of PACT in Microservices architecture?
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.
24. Can you give a gist about Rest and Microservices?
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 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?
While working with microservices, testing becomes quite complex as there are multiple microservices working together. So, tests are divided into different levels.
- 1. At the bottom level, we have technology-facing tests like- unit tests and performance tests. These are completely automated.
- 2. At the middle level, we have tests for exploratory testing like the stress tests and usability tests.
- 3. 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?
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?
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?
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?
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?
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.
31. What do you understand by Contract Testing?
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?
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 test where everything is tested after a particular period.
33. What is DRY in Microservices architecture?
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)?
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?
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.
Get Hands-on Practical Microservices Training with Instructor-led Classes
- Instructor-led Sessions
- Real-life Case Studies
36. What do you understand by Semantic monitoring in Microservices architecture?
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?
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?
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?
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 is the meaning of OAuth?
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.
41. What do you understand by Idempotence, and how is it used?
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?
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.
- 1. Code Scanning: In order to ensure that every line of code is bug-free and can be replicated.
- 2. Flexibility: The security protocols should be flexible as per the requirements of the system.
- 3. Adaptability: The security protocols should be adaptable to the malicious intrusions.
43. Why are containers used in Microservices?
Containers are the easiest and most 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.
44. How do independent Microservices communicate with each other?
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?
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:
- 1. Using a REST Template that is load balanced.
- 2. I am using multiple microservices.
46. How will you deploy Exception Handling in Microservices?
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.
- 1. Add @ResponseStatus for exceptions that you write.
- 2. For all other exceptions, implement an @ExceptionHandler method on a @ControllerAdvice class or use an instance of SimpleMappingExceptionResolver.
- 3. For Controller specific exceptions, add @ExceptionHandler methods to your controller.
47. What is Spring Batch Framework?
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?
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?
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?
Eureka is alternatively known as the Netflix Service Discovery Server. It uses Spring Cloud and is not heavy on the application development process.
51. What is the role of RESTful APIs in Microservices?
A microservice is based on the concept where all it’s component services require interaction 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?
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?
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:
- Remote Services
- Resource Leaks
54. How does a Microservice Architecture work?
Under a microservice architecture, an application is simplified into multiple modules that independently perform the single precise standalone task:
- 1. Are fragmented into loosely coupled various modules, each of which performs a distinct function.
- 2. It can be or are distributed across clouds and data centers.
- 3. 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?
- 1. Services split up and organized around business functionality.
- 2. Separate modules handled and owned by different development teams.
- 3. Decentralized Framework.
- 4. Maintenance of respective modules by respective development teams.
- 5. Separate modules may be maintained by different databases.
- 6. Modules in a Microservice Architecture are separately deployable. They can be updated, enhanced, or deleted without disrupting the entire architecture.
- 7. Real-time monitoring of the application.
56. What are the main challenges in Microservice Deployment?
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.
- 2. From a technical standpoint, the main challenges are:
- 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?
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?
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 microservices communicate with each other?
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?
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.
61. What is a CDC?
CDC is a 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?
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.
Are you looking training with Right Jobs?Contact Us
- Big Data and Hadoop Ecosystem Tutorial
- Big Data Applications Tutorial
- Data Analyst vs. Data Scientist
- Top Big Data Certifications for 2020
- What is Dimension Reduction? | Know the techniques
- Difference between Data Lake vs Data Warehouse: A Complete Guide For Beginners with Best Practices
- What is Dimension Reduction? | Know the techniques
- What does the Yield keyword do and How to use Yield in python ? [ OverView ]
- Agile Sprint Planning | Everything You Need to Know