Introduction
In the modern economy, the creation of software is an entire industry. On the one hand, it helps businesses to automate and digitalize all processes, and on the other hand, it makes a profit and creates virtual assets. Currently, R&D has become more complicated, the number of programmers is constantly growing, and IT tasks are becoming more complex.
These reasons have led to the emergence of new software development methodologies and types of architecture.
Modern web applications are multifunctional and the digital transformation increases the requirements for software. The application should be: easily scalable, flexible and cross-platform, and changeable for user tasks. Task managers set these requirements at the stage of developing such software.
Firstly, to create software for modern business you must seriously study the software development process and choose the right architecture.
The choice of architecture in software development
As a rule, previously all applications were developed based on a monolithic architecture. Let's take a look at what a monolith application is.
Monolithic apps are developed as a whole. The logic for processing requests is placed inside a single process.
Monolith web apps can be structured in the form of modules and blocks. Separate classes, functions, etc. are used, depending on the programming language used. But the connections between the modules are very strong.
This leads to the following conclusion: changing any module will greatly affect the working of the entire application.
For example, we can consider a typical web app for LMS (learning management system).This software has a three-level architecture, which includes:
- user interface;
- the server-side component for software business logic and data access;
- the database.
The business functions of such an application are very different. It includes the following blocks: "Courses and training", "Course Catalog", "Organizational structure of the company", "Calendar of Events", "Reports", "Messages", "News", etc.
However, they are all combined into a single monolithic block and are located on one server. It is quite difficult to scale and change such an application.
Let's highlight the disadvantages of monolithic architecture:
- Even a small change in a web app leads to the assembly and deployment of a new version of the entire software.
- You can only scale the entire application. It's impossible to scale a separate block.
- If any application module fails, then as a result, the operation of the entire application may be disrupted.
- Development tools are always limited to the selected tech stack.
- Inconvenience in managing a large team of qualified developers. Each developer should understand all the functionality of the app, not just his module.
- Any update affects the entire functionality of the software. It leads to the risk of application failure after updates. Therefore, only rare releases of updates are made.
- Any changes in the database can affect the working of the entire application and need changes in the code.
If this is a small free program for teaching some individual skills to an ordinary user, and even updated rarely, then a monolithic architecture is quite suitable for such development.If we are talking about corporate software (for example, LMS), and even frequently updated, then it is necessary to choose a microservice architecture.
Microservice architecture is the optimal approach to software development. In a microservice architecture, the web application is divided into small and autonomous components (microservices) with specific interfaces. Such architecture has found its application in the field of cloud computing.
What is the difference between microservice and monolithic architecture? In a microservice architecture, the web app is developed as a set of small and poorly interconnected components, which are called microservices. Microservices are developed, deployed, and maintained almost independently of each other.
For example, a web application for LMS. Each microservice is aimed at solving only its specific business task, has its database, and contacts with other microservices via the API. Thus, it will be necessary to develop the following microservices for the LMS web app: "Courses and training", "Course Catalog", "Organizational structure of the company", "Calendar of Events", "Reports", "Messages", "News", etc.
But it must be noted that there is another type of architecture — a service-oriented architecture (SOA). Sometimes it is confused with microservice. It seems that the differences between microservice architecture and SOA are not so obvious. But there are differences between microservices and SOA. This concerns the role of the enterprise service bus (ESB).
SOA is a company-wide architecture. Its goal is to standardize the interaction and integration of the company's web services. The purpose of microservice architecture is to develop a specific application. The following templates are related to SOA: CORBA, web services, message queues, ESB, etc.
Below we will tell in detail about the advantages of microservices for developing web applications.
The main advantages of microservice architecture
We will evaluate the advantages of microservices in comparison with a monolithic architecture.
- Simpleness and independence in application deployment. In the case of microservices, you can deploy only one application module. For example, in our case with LMS, you can deploy only one module ("Event Calendar"), leaving the rest of the application components unchanged. If you need to rewrite code in the "Reports" module, then there is no need to get a lot of permissions. This component ("Reports") is a separate and independent microservice.
- Scalability: accuracy and efficiency. Firstly, it need to determine which microservices will require frequent scalability, and which ones will not. Modules that don't need to be scaled often, can be placed on weaker servers, and often scalable ones can be scaled separately from all other software.
- Increased application resilience. Rational app design and building independent connections between modules give the following advantage: the failure of one of the modules does not lead to the failure of the entire software. For example, if the "Messages" module has failed, the user will receive a notification about the temporary unavailability of this block. All other application blocks will work.
- Tech stack selection. By developing each microservice, you can choose the most appropriate tech stack.
- Flexibility in managing teams. For example, team No. 1 develops the service "Course Catalog", team No. 2 — "Calendar of events", and team No. 3 — "News". That's why it's easier for a new specialist to get into work faster. It is not necessary to study the functionality of the entire application for a long time, it is enough to learn the tech stack for a specific microservice.
- The ability to reuse the functionality (for different purposes and in different ways).
- Replacement or removal of unnecessary services is solved quickly and easily. For example, if a specific customer will not use the "News" block in the LMS, then this module can simply be removed, without global changes in all software.
- Each microservice uses its database. This fact leads to the independence of data models. For example, if a programmer has changed the data model in one particular service, it will not affect the working of other services.
As we can see, microservice architecture has significant advantages and attracts developers more and more. However, before choosing an architecture for software development, it should be looking at the disadvantages of microservices. We will list the ones below.
Disadvantages of microservices
The system of microservices is distributed. On the one hand, this is an advantage in the work of the software. On the other hand, if there are too many microservices and each of them makes requests to other services, the resulting response time will increase, and "points of failure" will appear.
There are two ways to solve this problem:
- changing the call details, which may lead to a decrease in their number;
- the introduction of asynchrony, calls are performed in parallel, as a result, this leads to the fact that the final response time is the slowest time of all, and not the total time of all delays.
The constant complication of the development process, which leads to increased requirements for the qualification of programmers. In a microservice architecture, the role of integration processes and continuous delivery processes is great.
And that's why it's quite difficult to handle a lot of processes without automating testing and deploying services. These factors require the implementation of DevOps in the company and the close cooperation of developers with system engineers, testers, technical support, etc.
Decentralization in the microservice architecture creates problems with the consistency of microservices. For example, in a monolithic application, many changes can be made in one transaction, but it is also possible to roll back if a failure occurs, while maintaining data consistency.
When using microservices, the following situation is possible: in case of a malfunction of one of the services, the other microservice stop responding. In this case, it is a matter of the developer's priorities: you can give priority to the availability of components (in case of failure of one service, others will continue functioning). In general, developers must find a balance between the consistency of services and their availability, and this must be done very carefully.
Conclusions
Before choosing a microservice architecture for developing web applications, developers should evaluate both its advantages and disadvantages. After all, the wrong choice of architecture may affect the performance and functionality of the software in the future.
If the microservice architecture is used incorrectly, developers may have big problems that negate all the advantages of microservices.
In the next part of the article, we will consider the technical tools that a developer who is going to use a microservice architecture in software development should master.