Let’s talk about the pros and cons of microservices and find out who the technology is suitable for.
What Is Microservice Architecture?
Microservice architecture is a common approach to software development where an application is broken down into small, self-contained components (microservices) with well-defined interfaces.
Microservices vs. Monolith
Before starting a story about microservices, it is worth remembering another type of application that is most often opposed to them – monoliths. These are applications built as a single unit, where all the logic for processing requests is placed inside a single process. Of course, monoliths can have a modular structure – they contain separate classes, functions, and namespaces (depending on the chosen programming language). But the connections between these modules are so strong that changing each of them will inevitably affect the operation of the application as a whole.
Let’s take a typical online store as an example. A monolithic application for it will use the familiar three-tier architecture, which includes:
- user interface;
- the back end, which is responsible for the business logic of the application and access to data;
We see that the business functions of the application are very diverse: working with the product catalog and shopping cart, order processing, payment and status tracking, user management, and so on. But at the application level, they are all combined into one monolithic block. When deployed, the code for the various functions is on the same server. To scale an application, you need to run multiple instances of it on different physical servers.
The disadvantages of such a monolithic architecture scheme are obvious :
Redundancy of Assemblies And Deployments
Even a tiny change to one of the business functions will need to build and deploy a new version of the entire application.
Inability To Scale Part Of The Application
The entire application has to be scaled, even if necessary, for a single component with the lowest performance. In our example, we can assume that calls to the product catalog will occur much more often than ordering – that is, it would be worth allocating additional resources for this function, but this is impossible in a monolith.
Failure Cost Increase
The failure of one module most often affects the entire work due to the close relationships within the application.
Difficulty Introducing New Technologies
The developer is limited to the selected technology stack for the application. However, for several components to use other technologies.
A large team is required, which is challenging to manage. That said, the team structure is likely to match the chosen architecture: individual UI, business logic, and database specialists. And each of these groups will need expertise in all business functions, which will become increasingly complex over time.
Rarity Of Updates
Since the changes affect the entire application, the time for debugging and testing them increases, leading to rare updates and an increase in the number of released changes in one release, which increases the risks.
Heavy Reliance On The Data Model
Any change to the database will affect the entire application and require significant code changes.
For small and rarely updated applications, this architecture can work fine. But as the functionality increases, inter-module connections in a monolith will inevitably increase and become more complicated; changes in some modules will increasingly affect others. As a result, the further development of such systems becomes extremely difficult. And here’s an excellent time to take a closer look at microservices.
Unlike monoliths, in a microservice architecture, an application is built as a collection of small and loosely coupled components (microservices) that can be developed, deployed, and maintained independently of each other.
Each service is responsible for a specific business task, has its data stored, and communicates with other services through simple APIs to solve more complex problems. So, in our example, we can single out microservices for maintaining a catalog of goods, working with a basket, placing orders, paying, and so on.
Also Read: Human vs Digital Transformation: Virtual Games And The Skill Of Neuroplasticity