A simple explanation of micro-services. Also discusses some pro/cons of the micro-services.
Monolithâ
Whatâs a Monolith?â
A complex application with a broad scope and typically large codebase.
Generally monoliths also read/write to an external DB.
Consâ
- Tightly coupled application code.
- A change in one particular part of the system might affect another part of the system.
- Harder to reason about because the codebase is large.
- Due to its broad scope, multiple teams update the same codebase.
- Harder to scale.
- Harder to refactor.
- Support/Operations have a harder time maintaining a monolith because many things can go wrong.
What's a Microservice?â
A simple application with a limited scope.
Microservices can be both stateless or stateful (write to an external DB).
Prosâ
- Easy to reason about because of its limited scope and limited codebase.
- Easier to scale.
- Easier to refactor.
- Support/Operations become easier.
Moving a Monolith to a Micro-Service architectureâ
Advantagesâ
- Changes can be applied at a faster pace.
- Scaling
- Can now be done at different levels for different services.
- Can now be done at the regional level.
- Itâs now possible for the team implementing/owning the micro-service to choose the best tech stack for the job. The tech stack can be different for different micro-services.
- Different tech stacks werenât possible in a monolith because everything is the same code base.
- An individual micro-service can now be leveraged by a completely different application.
- This wasnât possible previously because the business logic for the micro-service was âembeddedâ in the monolith.
- Different Tiers can be implemented for every micro-service.
- Tier 0, Tier 1, Tier 2 etcâŠ
- Possibility of cheaper infrastructure costs due to different requirements like:
- Databases
- Caching
- Compliance
- Logging
- Data retention
Common Pitfallsâ
- Badly designed/documented interfaces.
- The interfaces of the micro-services canât be changed easily because you can âbreakâ âupstreamâ and âdownstreamâ functionality.
- Communications need to be sent out to the teams maintaining the âupstreamâ and âdownstreamâ services to ensure smooth releases.
- Creation of âminiâ monoliths.
- Creation of a âdistributedâ monolith.
- An âexplosionâ of micro-services
- Operations are harder.
- Integration testing is harder.
- Maintenance is harder.