Key Benefits Of Microservices Over Monoliths
Ease Of Deployment
Only microservices that change can be deployed independently of the rest of the system, allowing for more frequent and faster updates.
You can expand only those services that need it, that is, the services with the lowest performance, leaving the rest of the system to work on less powerful hardware.
Failure of one service does not stop the system as a whole. Once the bug is fixed, the necessary change can only be deployed to the appropriate service instead of redeploying the entire application. True, for this, even at the design stage of microservices, it will be necessary to carefully think over the connections between them to achieve maximum independence from each other, as well as lay the possibility of correctly notifying the user about the temporary unavailability of a particular service without prejudice to the entire system.
Choice Of technologies
You can select different sets of optimal technologies for solving the problems facing individual services.
Small Development Teams
When developing microservices, teams are usually assigned to specific business tasks (and services, respectively). These teams tend to be more effective and easier to manage.
Reducing Duplication Of Functionality
There is a possibility of reusing functionality for different purposes and ways.
Simplify Service Replacement When Needed
It is easier to replace small services with a more suitable version or remove them altogether – this carries significantly fewer risks than a monolithic application.
Data Model Independence
Each microservice usually uses its data store – so changing the data model in one service does not affect the operation of the others.
Disadvantages Of Microservice Architecture: How To Deal With Them
Despite the many advantages, microservices are not always the best option; they have several features that should be considered when choosing an architecture.
Microservices are inherently distributed, which is known to have its drawbacks: remote calls are slower and more prone to failure. If your microservice accesses a dozen other microservices, and those, in turn, call several more, then the resulting response time increases significantly. Also, as the interactions of microservices with each other increase, so does the number of possible points of failure.
There are several known ways to solve this problem:
- The first is to change the granularity of your calls in such a way as to reduce their number.
- The second is to use asynchrony: when several calls are executed in parallel, the final response time will be determined by the slowest and not the sum of all the delays.
Both methods add complexity to the programming model and increase skill requirements.
Complicating Processes And Growing Demands On The Team
The growth in small, independent services inevitably increases operational complexity. The role of continuous integration and delivery is growing as it is impossible to process dozens of services without automating their testing and deployment. Monitoring requirements are increasing, mainly due to the technological heterogeneity of services.
To cope with the increased workload, a company needs to master a range of new skills and tools, which is adopting a DevOps culture. It is necessary to ensure the close cooperation of programmers, testers, maintenance engineers, and other participants in developing a product at all stages of its life cycle. Not all organizations will be able to cope with so many changes. But cultural change is needed.
The Need To Maintain Consistency Of The Application
Microservices pose potential consistency issues due to their decentralized data management. You can make many related changes in a single transaction in a monolithic application. You can be confident that a rollback will occur in the event of a failure and will preserve data consistency.
On the other hand, Microservices require several resources to complete the chain of changes; distributed transactions are not welcome. Therefore, a situation may arise when, when updating one component, the other temporarily stops responding, waiting for the operation to complete on the first.
Of course, when developing certain services, you can give preference not to consistency but to availability: so that in the event of an update or failure of one service, others continue to work. But this must be done very carefully so that the business logic does not make decisions based on conflicting information.
Thus, if microservices are misused, they can negate many benefits. Therefore, most experts advise starting with a monolith, maintaining its modularity, and moving to microservices when needed and after preliminary preparation.