Microservices

 Monolithic Application: An application where every part of a product is part of the same service or web application. And usually, the data for the entire application is in a single data store.

Issues with Monolithic Application:

  1. Source code management in source control. Though you can break components up as NuGet packages but not always done.
  2. Tough to manage big team due to different part interdependency.
  3. Code and database deployments and rollbacks are a nightmare.

What is Microservices: Microservices are smaller single-responsibility services. Which does one thing only and has a clear boundary. And usually, they own their data and the data store.
The logic, as well as data of a single responsibility microservice, should not leak outside of it.

Fundamentals of Microservices:
  1. Loosely coupled multiple services
  2. Independently deployable
  3. Organized around business capabilities
  4. Owned by a small team
  5. Highly maintainable and testable
  6. Inter-service communication should take place through only public contact
Containers: Containers are used for packaging software and all of its dependencies into a standard unit for development, deployment and shipment. They are immutable.
Mostly use Docker.

Microservice Communication: 
  1. Most popular is REST API. (GRPC is  catching up quickly)
  2. Message based communication (Queue or Pub/Sub) (More flexibility for decupling)

How do I convert my Monolith to Microservices?
  • Bring out the most easily separable component from the Monolith first (Authentication, Authorization)
  • If you are using SQL server, your first option might be to make a service responsible for table set instead of an entire database.
  • If you are in cloud, use cloud native managed databases like DynamoDB in AWS or Cosmos DB in Azure.
How to generate reports: When data is available across multiple databases, getting a consolidated view of the data or report is hard.
You can either use data aggregation by calling multiple services. Or you can create a data stream for all the data and have an aggregator to create a read-only view of the data.


Comments