Why Not Microservices?
Published: 2023-03-19 20:20:36

#Introduction

Many organizations and teams may see microservices as the best approach to a determined problem. This post covers 5 basic concepts to think about when implementing this type of architecture. The idea is to revise some concepts that will help you question the need for this approach.

##1. Communication Services

**Microservices** are services that attend a certain domain and are released independently. These services could then be exposed to other services through API's, Service Brokers, or other communication services.

![Two API's](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g0lwkadqoh65u7rv946p.png)
<b>Figure 1 - Microservices through API's</b>

##2. Independent Deployability
Many consider independent deployability the most important piece to microservices. Applying this concept is necessary to validate that applications are loosely coupled. To certify this, one should be able to make changes to a specific microservice without having to change other services. 

![Releases](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8iostkoq2zbu0jnqkc1a.png)
<b>Figure 2 - Releases</b>

##3. Databases Sharing
It is highly recommended that each microservice contains its own database. When we think of a microservice as a unique piece of software it should have independence in all levels and that includes the database. When one or more microservice share the same database one can easily fall into the assumption of shared deployment or accessing the same data between these services.

![Database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7xmepha5s9u9fu9prcz.png)
<b>Figure 3 - Databases</b>

##4. Business Domain
With a microservice approach each microservice needs to be independent and organized. To effectively allow for independence, design techniques are commonly used like layered architecture, clean architecture, domain-driven design(DDD), etc. These approaches allows for teams to structure the code with independent contextualization efficiently.

![Business Domain](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qenbxu1rxef52hdhftj.png)
<b>Figure 4 - Business Domain</b>

##5. Client Communication 
With the growth of business and processes within an organization the tendency is that the number of services will also grow. However the consumers of these microservices needs to be able to effectively communicate or call the microservice for the desired job. There are a couple of strategies to solve this issue. Having an API gateway is a strategy to expose, version and evolve microservices effectively. 

![API Gateway](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qrt04uwynta7dz0qgli6.png)
<b>Figure 5 - API Gateway</b>

#Conclusion

This post contains only the tip of the iceberg when it come to microservices. To develop this type of solution more situations needs to be considered like the teams experience, deployment automation, cloud computing, security, scalability, testing, resilience, observability, organization alignment, etc. 

The increase in complexity and team experience when creating microservices are many times why these projects tend to fail. It is common to have less experience or reduced teams working on software projects, with the mindset of a microservice architecture.

Microservices are effective when used, planned, and executed in appropriate scenarios, but I always tend to ask myself why not microservices?

#References
1. Building Microservices: Designing Fine-Grained Systems