Microservice architecture – a variant of the service-oriented architecture structural style – arranges an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained and the protocols are lightweight. Here is a list of coding interview questions on Microservices to help you get ready for your next data structures interview in 2021.
- 1.
Define Microservice Architecture
Answer:
Microservices, aka Microservice Architecture, is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.
- 2.
List down the advantages of Microservices Architecture
Answer:
- Independent Development. All microservices can be easily developed based on their individual functionality
- Independent Deployment. Based on their services, they can be individually deployed in any application
- Fault Isolation. Even if one service of the application does not work, the system still continues to function
- Mixed Technology Stack. Different languages and technologies can be used to build different services of the same application
- Granular Scaling. Individual components can scale as per need, there is no need to scale all components together
Source: lambdatest.com - 3.
Why Would You Opt For Microservices Architecture?
Answer:
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.
Source: lambdatest.com - 4.
What are main differences between Microservices and Monolithic Architecture?
Answer:
Microservices
- Service Startup is fast
- Microservices are loosely coupled architecture.
- Changes done in a single data model does not affect other Microservices.
- Microservices focuses on products, not projects
Monolithic Architecture
- Service startup takes time
- Monolithic architecture is mostly tightly coupled.
- Any changes in the data model affect the entire database
- Monolithic put emphasize over the whole project
Source: edureka.co - 5.
What are the standard patterns of orchestrating microservices?
Answer:
As we start to model more and more complex logic, we have to deal with the problem of managing business processes that stretch across the boundary of individual services.
With orchestration, we rely on a central brain to guide and drive the process, much like the conductor in an orchestra. The orchestration style corresponds more to the SOA idea of orchestration/task services. For example we could wrap the business flow in its own service. Where the proxy orchestrates the interaction between the microservices like shown in the below picture.
With choreography, we inform each part of the system of its job, and let it work out the details, like dancers all find‐ ing their way and reacting to others around them in a ballet. The choreography style corresponds to the dumb pipes and smart endpoints mentioned by Martin Fowler's. That approach is also called the domain approach and is using domain events, where each service publish events regarding what have happened and other services can subscribe to those events.
Source: stackoverflow.com - 6.
Whether do you find GraphQL the right fit for designing microservice architecture?
Answer:
GraphQL and microservices are a perfect fit, because GraphQL hides the fact that you have a microservice architecture from the clients. From a backend perspective, you want to split everything into microservices, but from a frontend perspective, you would like all your data to come from a single API. Using GraphQL is the best way I know of that lets you do both. It lets you split up your backend into microservices, while still providing a single API to all your application, and allowing joins across data from different services.
Source: stackoverflow.com