Wednesday, 18 September 2019

microservices interview questions

Q 1- What is microservices?


Definition Of Microservices

it is a framework which consists of small, individually deployable services performing different operations.

monolithic vs. microservices
Microservices Architecture -

Microservices focus on a single business domain that can be implemented as fully independent deployable services and implement them on different technology stacks.

Microservices architectures make applications easier to scale and faster to develop, enabling innovation and accelerating time-to-market for new features.





Key Concepts Of  Microservice Architecture



  • Each microservice you design shall concentrate only on one service of the application.
  • Ensure that you have designed the application in such a way that each service is individually deployable.
  • Make sure that the communication between microservices is done via a stateless server.
  • Each service can be furthered refactored into smaller services.

Microservice Architecture should contains following components-



  1. Clients
  2. Identity Providers
  3. API Gateway
  4. Messaging Formats
  5. Databases
  6. Static Content
  7.  Management
  8. Service Discovery
Image result for Architecture Of Microservices รข€“ Microservice Architecture

1. Clients
 there could be different kind of clients from various devices which are trying to perform some activities such as searching, build ,configure etc.

2. Identity Providers
authenticate the requests from client and and communicate these requests with api gateway.

3.API Gateway
API Gateway acts as an entry point for the clients to forward requests to appropriate microservices.
advantages of using an API gateway include:


  • All the services can be updated without the clients knowing.
  • Services can also use messaging protocols that are not web-friendly.
  • The API Gateway can perform cross-cutting functions such as providing security, load balancing etc.

4. Messaging Formats



There are two types of messages through which they communicate:

  • Synchronous Messages: where clients wait for the responses from a service, Microservices usually tend to use REST (Representational State Transfer) as it relies on a stateless, client-server, and the HTTP protocol. This protocol is used as it is a distributed environment each and every functionality is represented with a resource to carry out operations


  • Asynchronous Messages: In the situation where clients do not wait for the responses from a service, Microservices usually tend to use protocols such as AMQP, STOMP, MQTT. These protocols are used in this type of communication since the nature of messages is defined and these messages have to be interoperable between implementations.
5. Data Handling
Well, each Microservice owns a private database to capture their data and implement the respective business functionality.Also, the databases of Microservices are updated through their service API only.

6. Static Content
After the Microservices communicate within themselves, they deploy the static content to a cloud-based storage service that can deliver them directly to the clients via Content Delivery Networks (CDNs).
7. Management
balancing the services on nodes and identifying failures.
8. Service Discovery
Acts as a guide to Microservices to find the route of communication between them as it maintains a list of services on which nodes are located.

Pros and Cons of Microservice Architecture

Refer to the table below.

Pros Cons 
Users are free to use different technologiesIt Increases troubleshooting challenges
focused on single business capabilityIncreases delay due to remote calls
Supports individual deployable unitsIncreased efforts for configuration and other operations
Allows frequent software releasesDifficult to maintain transaction safety
Ensures security of each serviceTough to track data across various service boundaries
Multiple services are parallelly developed and deployedDifficult to move code between services

Microservice Registration with Spring cloud using Netflix Eureka

No comments:

Post a Comment

Note: only a member of this blog may post a comment.