Frequently asked Microservices Interview Questions is designed for beginners and experienced candidates who are going to attend any interview. In this section we will cover Microservices, Monolithic Architecture, Docker, Domain Driven Design and much more which will help you to know the whole concept why you should use Microservices?
Table of Contents
What are Microservices?
Microservices are small independent services that work together independently and communicate with each other directly using the HTTP protocol. The aim of this approach is to achieve small autonomous services that focus towards a common business goal.
If there are 10 tasks in a particular business domain, each microservice will focus on only one task. So there will be 10 related tasks for 10 microservices.
What are the advantages of microservices?
There are following advantages of microservices:
- Independent development : For each functionality you can develop a separate service and you can manage it and control it totally.
- Independent Deployment : If we develop the service separately then we can go ahead and deploy that service. We do not need to wait for other services to be ready or for the architecture to be completed. If change is required in any particular service then we can make changes in that particular service and deploy that service yourself.
- Fault Isolation : If the particular service goes down then it does not affect the functioning of the other service.
- Mixed Technology Stack : Since we have separate independent service and we have independent approach to develop that service. We can choose the appropriate technology to develop that service. so accordingly we can have mixed technology to develop all architecture
- Granular Scaling : Since we have an independent service, we can scale the services independently.
How do microservices interact with each other?
HTTP helps both the services to communicate with each other. They can send or receive data in json, xml format using REST process. The sender or receiver service can serialize or deserialize the json/xml data.
Why is Spring Boot preferred for microservices in Java?
Microservices are independent and standalone. Spring Boot is the best option for us to achieve all this. That’s why we prefer SpringBoot.
What is meant by Standalone and Independent?
Whatever service you develop, it should be independent of others. And service should be standalone because we have container support, in that we can take all container support, run in tomcat and that project can work standalone, we can run on desktop or cloud as well as web server if needed.
How to communicate with each other if there are more than two microservices?
Microservices communicate with each other through RestTemplate. If you have more than 100 microservices we use service discovery pattern to communicate with each other
What is Domain Driven Design (DDD)?
Domain Driven Design is an approach that helps you to collaborate all the team together and also helps you in simplifying the creation of complex applications. It focuses on core domain and logic and DDD approach helps us to understand the problem and it also helps us to design software with general understanding.
Explain the monolithic architecture in details.
If we have a single code base consisting of multiple modules. Suppose we created a project and put many modules in it and there is only one database and you are working on it. It is a monolithic application. If we design a project in this way we can say that we have followed a monolithic architecture.
For example, if we have an ecommerce website, in which we are putting the shipping module, we are putting the purchase module, we are putting the payment module. That is, modules of different sections are working on the same project.
What are the advantages of monolithic application?
- It is easy to develop because you will have one project and all the resources in one place. because there can only be one type technology and database for all modules.
- It is easy to build and easy to deploy. Create a jar file and deploy this jar file, the complete application will be available on the server. You don’t need to deploy multiple modules with multiple jars.
- If you have a project and there are two modules m1 and m2, both the modules will run on the same server, then communication will be easy and there will be no network delay in terms of interconnectivity in this case.
What are the disadvantages of monolithic application?
- It is difficult to manage if we increase the size of the project by adding other functionalities.
- If we make a single change then we have to redeploy the whole application.
- In case of monolithic design, it is difficult to adopt new technology for particular functionality if we want to use other technology in that application. For example, we have a project in which we are using Oracle database and it will be difficult if we want to use MongoDB for a particular module.
- If we find any bug in the application then that one bug may take down our whole application.
What is the use of OAuth?
OAuth helps us to establish communication between different sites to share resources without exposing the password.
OAuth is Open Protocol or Open Authorization Protocol. It is the way to authorize two systems / services, using this protocol those services establish trust between each other and share their resources.
Explain Semantic monitoring in Microservices?
Semantic monitoring is basically a monitoring individual flow which ensures that the test is done and working fine at all times.
What is a Consumer-Driven Contract (CDC)?
It’s about being aware of who the consumer is, what they want at all times, what are the changes they’ll need and what you need to do to support the consumer ‘s needs.
It is basically the idea of specifying to the client what is the contract for the microservices.
What is the need of Docker?
It’s a container environment in which you package microservices exactly as you want to deploy them so that you don’t have to worry about configuration every time you just deploy/invoke a Docker image.
What are the Spring Cloud?
During development we may face some difficulties in deployment of services and applications and it may take time to build or deploy the application. For this scenario, Spring Cloud allows us to build services and applications quickly. And that application or service can work in any distributed environment.
What is end-to-end (E2E) Microservices Testing?
End-to-End makes sure whether the software workflow designed by us is working fine or not. End-to-end testing will enhance the quality of software and help us find dangerous bugs that may affect microservice users. If our end-to-end test fails, it will halt the delivery of all involved microservices.
What do you understand by Client Certificate?
The server uses the Client certificate to authenticate the client and it validates the identity of the client. Digital files are used for this purpose on the server.
After authentication client can send request to server or remote server to get resource.
How to maintain ACID in Microservice architecture?
You can maintain the ACID using a two-stage commit. A two-stage commit ensures that services must commit or roll back all transactions once the transaction is complete.
What is a contract PACT in Microservice?
PACT provides support for consumer-driven contract testing. It is basically a family of testing frameworks. It is an open source framework that provides facility of component testing based on contracts.
In other words, we can say that PACT is the contract between the application of consumer and application of service provider. Using contract testing increases the reliability of the application.
Explain the Continuous Monitoring in Microservices?
Using continuous monitoring, key risks are identified and tracked in real time. It also detects compliance and security threats in their SDLC and infrastructure.
Continuous monitoring mainly includes Infrastructure monitoring, Application monitoring, Network monitoring. By using continuous monitoring we can reduce the system downtime, enhance operational, security and business performance.
What type of testing do we use in microservices?
In microservices we mainly use three types of testing which are as follows:
- Bottom Level Testing : It includes Unit test.
- Middle-Level Testing : It includes Stress and Usability test.
- Top Level Testing :In this level of testing we mainly perform acceptance testing.
In what type of application should we use microservices?
We can use microservices to develop any kind of applications where security is concerned, modularity is required, isolation between modules is required.
We can develop Desktop, Web Application, Mobile App, Smart TV etc.
What is the major difference between Coupling and Cohesion?
Our applications can be made up of multiple modules. Each module can be independent or related to each other. Let’s say there are two modules M1 and M2. The relationship between M1 and M2 is Coupling.
There may be other possibilities that a single module may contain multiple parts. So the relationship between two and more than two parts within a module is a Cohesion.
What are Reactive Extensions in Microservices?
Reactive extension is the design approach in which we combine the responses of all the calls into one result and then get that combined result as a response.
It is also known as Rx. It is very popular in distributed environment and is the exact opposite of legacy flow.
What is API Gateway in Microservices?
API Gateway is a microservices architecture pattern. API Gateway is a server that merely serves as a portal into the system. The API Gateway receives whatever request the client sends, and the API Gateway directs the request to the appropriate microservice
The Netflix API Gateway is an example of an API Gateway.
What is blue and green deployment?
A blue and green deployment approach is one in which two different but identical environments are created. The environment in use is known as Blue Deployment, in other words the environment in which the current application version is running.
And the environment you wish to upgrade is known as green, which refers to an environment that is running the new/latest version of the application.
FAQ – Microservices
Spring Boot, Eclipse MicroProfile
If the software needs to be updated regularly and the developer needs to build large, enterprise-level apps. Microservices should be used in this scenario.