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:
- Source code management in source control. Though you can break components up as NuGet packages but not always done.
- Tough to manage big team due to different part interdependency.
- 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:
- Loosely coupled multiple services
- Independently deployable
- Organized around business capabilities
- Owned by a small team
- Highly maintainable and testable
- 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:
- Most popular is REST API. (GRPC is catching up quickly)
- 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
Post a Comment