Thursday, February 2, 2023

MicroServices

 

 1. What is MicroServices?

Microservices are an architectural and organizational approach to software development where software is composed of small independent services that communicate over well-defined APIs. These services are owned by small, self-contained teams.

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

For more refer Microservices and Microservice Architecture.

2. Monolithic vs. Microservices Architecture

With monolithic architectures, all processes are tightly coupled and run as a single service. This means that if one process of the application experiences a spike in demand, the entire architecture must be scaled. Adding or improving a monolithic application’s features becomes more complex as the code base grows. This complexity limits experimentation and makes it difficult to implement new ideas. Monolithic architectures add risk for application availability because many dependent and tightly coupled processes increase the impact of a single process failure.

With a microservices architecture, an application is built as independent components that run each application process as a service. These services communicate via a well-defined interface using lightweight APIs. Services are built for business capabilities and each service performs a single function. Because they are independently run, each service can be updated, deployed, and scaled to meet demand for specific functions of an application.

 

3Characteristics of Microservices

Autonomous

Each component service in a microservices architecture can be developed, deployed, operated, and scaled without affecting the functioning of other services. Services do not need to share any of their code or implementation with other services. Any communication between individual components happens via well-defined APIs.

 

Specialized

Each service is designed for a set of capabilities and focuses on solving a specific problem. If developers contribute more code to a service over time and the service becomes complex, it can be broken into smaller services.

4. What do you understand about Autonomous of a MicroService?

A MicroService is 

  • Independent of other services, 
  • Easier to deploy, 
  • Maintain 
  • Can be developed by a small team or one member. 
  • If anything goes wrong with a MicroService it does not cause system failures since the MicroServices are autonomous.

5. What do you understand about the Cohesive of a MicroService?

Cohesion is the way to identify how to group related functionalities if they are part of the same domain and how to break apart or delegate to different MicroService if the functionality belongs to a different domain boundary. 

A high cohesive MicroService follows a single responsibility principle as It implements or group relation functionality and independent functionality is developed by other MicroService. 

For more visit Identify domain model boundaries and MicroServices Properties.

6. What is Bounded Context?

Bounded Context is a pattern that is used in DDD - Domain-Driven Design. It's a part of DDD and deals with large domain models. Domain model is an object model which incorporates both data and behavior. DDD deals with these large domain models by dividing them into Bounded contexts. In other words, One MicroService is implemented for one bounded context or one domain model. For more visit - BoundedContext.

7. What is Domain-Driven Design? Or MicroService is DDD specific?

DDD (Domain-Driven Design) means - designing an application based on models of underlying domain. A model consists of both data and the behavior of the domain. MicroServices are DDD specific, means - One service is responsible for the implementation of one domain-model.

For example, there are two domain models Sales and Support then DDD will deal with this situation by dividing these models into two bounded contexts. Hence you need two explicitly interconnected MicroServices for these two different bounded contexts.

8. MicroServices are technology agnostic. Explain it.

In MicroServices architecture,  MicroServices can be developed using any tech stack such as Java, .NET, Node.js, any hardware or software which best fits to the requirement.

9. What are the benefits of MicroServices?

MicroServices Architecture offers many benefits because of its characteristics.

Agility

Microservices foster an organization of small, independent teams that take ownership of their services. Teams act within a small and well understood context, and are empowered to work more independently and more quickly. This shortens development cycle times. You benefit significantly from the aggregate throughput of the organization.

 

Flexible Scaling

Microservices allow each service to be independently scaled to meet demand for the application feature it supports. This enables teams to right-size infrastructure needs, accurately measure the cost of a feature, and maintain availability if a service experiences a spike in demand.

 

Easy Deployment

Microservices enable continuous integration and continuous delivery, making it easy to try out new ideas and to roll back if something doesn’t work. The low cost of failure enables experimentation, makes it easier to update code, and accelerates time-to-market for new features.

 

Technological Freedom

Microservices architectures don’t follow a “one size fits all” approach. Teams have the freedom to choose the best tool to solve their specific problems. As a consequence, teams building microservices can choose the best tool for each job.

 

Reusable Code

Dividing software into small, well-defined modules enables teams to use functions for multiple purposes. A service written for a certain function can be used as a building block for another feature. This allows an application to bootstrap off itself, as developers can create new capabilities without writing code from scratch.

 

Resilience

Service independence increases an application’s resistance to failure. In a monolithic architecture, if a single component fails, it can cause the entire application to fail. With microservices, applications handle total service failure by degrading functionality and not crashing the entire application.

10. What do you understand about Resiliency in MicroService Architecture?

  • Resiliency refers to the ability of a service to recover from failures and continue to function in previous state. 
  • It does not mean to avoid the failures but accepting the fact that  there should be minimal data loss and downtime. 
  • The Primary goal of resiliency is that a system or application should return to a fully functioning state after a failure.
  • You should design your systems to be resilient to partial failures like Network outage, VMs crashes which will certainly occur eventually. 

For more visit Resiliency in MicroServices.

11. What are key Principles of MicroServices?

MicroService design has IDEALS Principles similar to Object oriented design has SOLID principles.

  • I - Interface Segregation Principle
Interface segregation tells us that different types of clients (e.g., mobile apps, web apps, CLI programs) should be able to interact with services through the contract that best suits their needs. 
  • D - Deployability (is on you) Principle
Deployability (is on you) acknowledges that in the microservice era, which is also the DevOps era, there are critical design decisions and technology choices developers need to make regarding packaging, deploying and running microservices. 
  • E - Event-Driven Principle
Event-driven suggests that whenever possible we should model our services to be activated by an asynchronous message or event instead of a synchronous call.
  • A - Availability over Consistency Principle
Availability over consistency reminds us that more often end users value the availability of the system over strong data consistency, and they’re okay with eventual consistency. 
  • L - Loose-Coupling Principle
Loose-coupling remains an important design concern in the case of microservices, with respect to afferent (incoming) and efferent (outgoing) coupling.
  • S - Single Responsibility Principle
Single responsibility is the idea that enables modeling microservices that are not too large or too slim because they contain the right amount of cohesive functionality.

 

 

 

No comments:

Post a Comment