As the name suggests Microservices mean services that are developed to fulfill a small set of service and business capabilities like Swiggy or Zomato that deliver the food. These services are highly maintainable and testable. And in the current time, every small and giant company is using Microservices, so it is obvious that an interview may ask you about this topic while you are interviewing for the role of any technical position in any company.
So here we are including the top most important and commonly asked questions that you need to remember and the interview can ask you if you are applying as a fresher, or have 1-2 years of experience in the technical domain.
What are Microservices?
Microservices are the service-oriented architecture that is used to build large applications using the combination of small services in which all the modules are independent of each other but deliver complete functionality as a service. Just like on amazon shopkeepers’ registration, product listing, product purchasing, shop packing, amazon warehouse packing, and delivery are all small services that all are independent of each other but make a large application to use.
Why is Microservices architecture preferred over monolithic architecture?
Because In monolithic architecture if a single functionality or any component goes down or breaks then the complete service could go down. But in a microservice architecture, all the modules are independent of each other. So if anyone’s functionality breaks down then it would not affect any other module or service.
What are the 3 main benefits of using Microservice?
The benefits of using Microservice architecture are:
- Independent deployment – Microservice used small modules that are completely independent of each other. So it gives a system power to not lose other functionalities if any one module gets failed or breaks.
- Satisfy business requirements – Microservice architecture is developed according to fulfill business requirements and can also add numerous functionalities.
- Rapid and continuous development – Using microservice we can develop a service way faster and also can automate the software updating and release of new versions.
Is it easy to automate a Microservice?
It is a challenging part in terms of automating a microservice because it consists of numerous small modules and services. And for each service, we need to automate the things for automating a complete service.
What are the challenges we need to face while using Microservice?
Communication – In a microservice, each service needs to communicate or send data to the other. Because without sending the proper response the system can stick to a stage.
Delay – sometimes a system can delay because of the remote functionalities used in the system.
Difficult to Maintain – sometimes it gets difficult to maintain because of the large number of functionalities involved in a system.
Which annotation is used to create the RESTful APIs?
The @RestController annotation is used to create the RESTful APIs.
Which annotation is used to handle the incoming request?
The @RequestMapping annotation is used to handle the incoming HTTP request.
Why do we need a Consumer-Driven Contract in our Microservice?
Using Consumer-Driven Contracts the outer service can easily use or communicate with our system. So that’s why we need CDC in our microservice.
What is the Incremental approach?
The incremental approach means providing the fixes for the current problem and updating the system rather than releasing a big update.
Why do we need DevOps in microservice?
Because the requirements that a microservice needs is the key feature of DevOps technology. And the automation, frequent releasing of software, and standardization can easily be done by using DevOps.
What is Unit testing?
In Unit testing of microservice, we use testable software that can determine if our system is working as expected or not.
What is Load balancing?
Load balancing is an approach to avoiding application failures if a data center goes down then we can route all the other requests to another available data center.
What is a Loose Coupling?
Loose coupling means when we make changes to one service then the related service is not required to change anything.
What are Monolithic applications?
Monolithic applications are applications that are built as a single unit and all the business functionalities are piled in a single monolithic application.
What is Resilience?
Resilience is a measure of the capacity of a system to recover quickly from a failure. This function enables a system to quickly deal with failure without causing the other components to fail.
Which annotation is used for Unit Testing?
The @WebMvcTest annotation is used for Unit testing of an MVC component.
Explain microservice implementation using one Example.
An online store is a good example of a microservice where the complete system is built using small services including online signup of the user, login, purchase of a product, packaging of the product, delivery of the product, user review, replacement of the product, etc. also all the services need to communicate with each other for smoothly running of the system. And also all the services are completely independent of each other.
Why do we need a database in Microservices?
The database is the system that stores the information and in the Microservice implementation of a system, all the services need to communicate with each other to not get stuck in a situation. So the database is the system that stores all the information generated by the service and using the stored data service can easily communicate with another service.
What is the use of APIs in Microservices?
APIs are the application programming interface that is used to give an interface to a user that fulfills a user’s requirements or we can also say it is the entry point of a service where the user can navigate to other services. Just like if a user wants to sign in on a website then there is a separate page for that.
Define the Main Three elements of a Microservice.
The main three elements of a microservice are Frontend, backend, and database.
- Frontend – It is the client-based interface that a user can see and enable a user to communicate with the system.
- Backend – It is the interface that usually users can’t see and used to send and received and request data from the database to the frontend.
- Database – It is the system that stores the data of the system and enables a system to analyze its performance.
Define the layers of a Microservice ecosystem.
Hardware layer – This layer includes all the hardware that enables a microservice to run on a system.
Communication layer – This layer handles the communication between the services.
Application layer – This layer includes all the tools and services that are independent of each other.
Microservice layer – This layer includes all the configuration of the application and where the actual system lives.
Why do we need a deployment pipeline for a Microservice?
Because after releasing the Microservice in the actual environment the deployment of new code becomes very difficult. So using the deployment pipeline it becomes easy to add the new service and code into a microservice.
What is the role of using GitHub in a Microservice system?
GitHub is used as a version control system where we can store our actual version and the new releasing version of the system with the code and can easily search, track and release the bundle.
What do you mean by Modularity?
Modularity means sets of some units that are completely independent of each other and can be used to make a large complex application or system. And the units are called modules.
What do you mean by Connascence?
If we make some changes to a module then to run the system we need to make changes to another related module is called Connascence.
Why do we need a Client Certificate for a Microservice?
It certified that the request made by a client to the system is authenticated and cannot harm the system in any way. It also checks the user’s information like location etc.
Why we can’t use Microservice for a new project?
Because to use microservice, we need more experienced developers and sometimes it gets difficult to handle all the parts of the system and need more developers to maintain the system.
Why spring boot framework is good for Microservices?
Because Sprint boot is a framework that needs minimum configurations to get started with the project and is used to build stand-alone applications that are completely independent and can be easily deployed on any platform.
What is Scaling?
Scaling means adding or implementing new features to the system. So we can improve the durability, security, performance, and maintenance power of the system.
Why we use Aggregator Pattern in Microservices.
Because using an Aggregator pattern the module can call services as per requirements. so the load can be balanced on the service. it also helps the system to communicate with outer systems.
Why do we use the Open Authorization protocol?
It is also called OAuth protocol, using this protocol other third-party applications like GitHub, Twitter, Facebook, and Instagram can access the application using HTTP requests without exposing the user’s data.