In this article, I wanna share my thought about migrating a system from monolithic architecture to microservices architecture. Is it easy game or not. Let’s start!
Monolith Architecture
A monolithic application has single code base with multiple modules. Modules are divided as either for business features or technical features. It has single build system which build entire application. It also has single executable or deployable binary.
Microservices Architecture
A microservices architecture consists of a collection of small, autonomous services. Each service is self-contained and should implement a single business capability.

When do migration?
- The system has high requirements related to reliability and scalability
- The expected product development requires involving more than one team
- The product needs quick and independent deployment because microservices allow for fast, independent delivery of individual parts within a larger, integrated system
How much the cost to do migration?
- Complexity: the entire system as a whole is more complex especially when the number of services increases.
- Development and Test: refactoring across service boundaries can be difficult. It is also challenging to test service dependencies.
- Data Integrity: with each microservice responsible for its own data persistence. As a result, data consistency can be a challenge.
- Network congestion and latency: when one business requires involving a lot of services dependencies, the latency can become a problem.
- Management & Versioning: It could have problems with backward or forward compatibility when updating version of services.
- Development team Skillset
Let’s try doing sample to migrate from monolithic to microservices. Take a look the exchange usecase below
- Multiple users are using exchange for trading
- Exchange receives buy/sell orders
- Exchange matches orders between buyers and sellers
- Exchange broadcasts updated order book to all users

The monolithic architecture should be

To migrate to microservices architecture, we should do something below
- Separate API to multiple smaller APIs
- Using Event Bus (Publish–Subscribe pattern) to communicate all services
- Using Api Gateway to aggregate as a single entry point into a system
The system now should be like this

Sample
https://github.com/trietdvn/ExchangeNetCore
Summary
From simple sample, it takes much effort to do migration and quite hard for testing and deployment.
Microservices are the latest software architecture trend, it can make more valuable but not a God. Personally I wanna recommend undertaking on a careful consideration process before diving in. Migrating monolithic to microservices could be more shit than we think.