Microservices Architecture
Last updated
Last updated
Different from the Monolith architecture, or gathering all modules into one block (monolith), we separate the modules into micro services. Each service will be placed on a separate server (Can use a cloud server like AWS or Azure), communicate with each other via the network (Send and receive messages via HTTP protocol or use MessageQueue). In simple terms, Microservices is a style of software architecture. Modules in this software are divided into very small services (microservices). Each service will be placed on a separate server -> easy to upgrade and scale the application.
The figure below illustrates that the software is built according to the Monolith architecture, an application will contain all components.
The picture below illustrates the above application when built according to Microservices architecture
Microservice architecture consists of a number of small, well-designed components that interact through messages.
Nowadays, applications are often very large and constantly updated, such as Facebook, linkedin,... . With monolith architecture, consolidating the entire application into one working block for upgrading becomes difficult and time-consuming. To solve that problem, large applications need to be separated into small services. Each service manages a separate database, located on a separate server, completely separate from each other. The advantages are as follows:
The most important thing is that it is very easy to upgrade and scale up and scale down. Suppose you make a website related to transportation and warehousing. When the number of vehicles or goods increases, you only need to upgrade the server for services related to logistics operations (on the contrary, you can reduce the server if necessary). With cloud computing, upgrading servers is extremely easy with just a few mouse clicks. This is very difficult to do with monolith.
Due to separation, if one service fails, the entire system still operates normally. With monolith, one faulty module can bring down the entire system.
Services are separate, they can use separate programming languages ​​and separate databases. For example, image processing services can be written in C++, data synthesis services can be written in Python.
Can apply automation processes, such as build, deploy, monitoring,...
When services are broken down, team size will decrease and everyone will work more efficiently
...
Modules communicate over the network so the speed may not be as high as monolith. In addition, each module must resolve issues of security, transactions, connection errors, and log files management.
Ensuring uniformity in data becomes more complex
Using many services makes monitoring and managing these services more complicated
Need a good team to design and implement including a good software architect
Which architecture to build software on completely depends on the scope of the problem that the application poses. Currently, according to my assessment, Monolith is suitable for small and medium-sized applications, while Microservices will be suitable. With large applications => we need to consider carefully when using to avoid the situation of carrying a buffalo scalpel to meat chicken =)). Through this article, I hope to share some of the general knowledge I have learned. Thanks!