You are brewing your morning Coffee at your work and you are hearing
words such as DevOps, CI/CD, Microservices, Docker.. well, you are not
alone..Most of the companies are at least trying to start microservices
for a new development..or they are thinking to migrate from existing
monoliths. Before we deep dive into that topic, let's try to understand
what is monolith(traditional web/ear) application. Monolith is usually a
single large web app which has everything built-in. A small code change
in UI requires a build, deployment and test, even you did not modify
code in business or data layer. Also, if you would like to scale out a
particular layer, it is difficult as it requires a deployment of whole
WAR on new instances. Here comes the Microservices to solve some of the
issues.
What is microservices?
Breaking a large application into a set of simple services, also called as functional decomposition.
Each services can be independently developed and deployed
Modular approach to system-building
Each service have its own persistent storage
Microservices are independent in code, technology, scaling.
Architecture difference between Monolith and Microservices
Microservices
is an architectural approach of breaking application (functional
decomposition) into smaller services where each service can be
independently developed, deployed with no limitation to technology
stack. Yes. It can be scaled out without impacting other services.
But
trickier question is when should I use use microservices? Answer is it
depends..If you are developing a large or complex application from
scratch, start with microservices architecture by separating UI,
business and data layers. If you already have a large app deployed to
production which becomes a hard mountain to climb, you can address this
problem in this way.
How to re-factor your existing monolith into microservices architecture?
- Implement any new functionality as microservice.
- Split the presentation components from the business and data layer.
- Incrementally refactor your application into a set of microservices without fully decommissioning the monolith app.
- Re-factor your monolith incrementally.
Here are some of the best but simple practices to consider when developing microservices.
Best practices on developing Microservices
- Design for failure(fault tolerance)
- Use one repository per service
- Each service should have independent CI/CD pipeline
- Each service should be loosly coupled
- Incrementally refactor your application into set of microservices when migrating from monolith
- Create a separate data store for each microservice.
- Deploy microservices in containers(docker)
There are few drawbacks too when implementing them.
Drawbacks of Microservices
- Developing distributed system can be complex.
- Multiple databases and transaction management can be painful.
- Testing Microservices based application can be cumbersome.
- Deploying Microservices can be complex as it requires co-ordination among multiple services
No comments:
Post a Comment