Moving the web portal: from monolith to microservice architecture
We share the experience of modernizing the architecture of the web portal, which made it possible to make the product convenient, stable and fault-tolerant: traffic increased from 350 thousand to 7 million users! The story will be useful to those who plan to expand their product. First, we’ll look at what factors can interfere with the work and development of the web portal:
Case A
client contacted us, whose web portal needed further development. At a certain point, a ceiling of 350 thousand unique visitors was reached every month. This seemed insufficient - the project clearly had prospects, and we had to find out what exactly stood in the way of further scaling the resource.
Audit
It turned out that the old Bitrix engine was not adapted to loads and scaling. Every single component of the system closely intersected and depended on each other. Constantly fixing bugs was such an excruciating task that we proposed a flexible and understandable microservice architecture. In them, each component is independent enough so that the errors inside it do not “hurt” the remaining elements of the system.
Bitrix remained the basis of the architecture - at least, authorization is tied to it, but where it was possible and promised great efficiency, we transferred the functionality to microservices. They became the cornerstone of the project.
The new combined architecture has provided us with stable, faster operation of systems and an almost complete absence of errors on some modules. It also served as the basis for the effective work of marketers. Thanks to the improved architecture, promotion specialists managed to increase the attendance of the resource by 20 times.
Microservices
We have selected modules such as file loader, search, and news feed as independent microservices. In addition to these user-friendly and obvious things, many other functional elements were implemented in the form of microservices:
In addition to all of the above, we have created many microservices for convenient work with the admin panel.
Each functional block of the site has become a fairly autonomous unit. A dedicated process is used for loading and rendering, minimizing intersection with other services.
Agree, when a user makes a payment, he will not want to wait a long time for loading the script responsible for playing the video he does not need in another part of the page. Indeed, this is what happens in monolithic systems - side functionalities sometimes interfere with the work of really important components.
We took the first step and made life easier for both users and developers, releasing more than 20 new services in a year. As a result:
Upgrading the technology stack
In parallel, we updated the technology stack. If the portal was originally based on php 5.6 and MySQL 5.6, then in the course of improving the engine, we switched it to php 7.0 and MySQL 5.7. Implemented the Yii2 framework, provided memcache caching.
Task Queue
In order to better parallelize tasks, we have transferred web workers - internal handlers - to the RabbitMQ queue. It optimizes the sequence of triggering events, which reduces the load on the system. Working with the site has become much faster and more comfortable.
Continuous Integration A
transparent and manageable development process is supported with GitLab CI. This is a truly continuous seamless development that leaves programmers and testers more time with important questions instead of patching holes.
In order to minimize errors, we introduced additional development loops. The chain consists of several application and infrastructure testing loops: pre-release, where the latest assembly testing (pre-prod), combat (prod), several test loops for testing several builds at once, as well as a loop for developers, are held. Assembly
system
At the initial stage, builds are created from the project sources. Instead of a disparate set of classes, styles, and handlers, combined entities are used - each in the shell of one executable file. Only necessary constructions are placed in the assembly for performing events on the page. This additionally provides flexibility and speed of the site.
Error monitoring
GitLab CI provides advanced features for code validation and automated testing. At the slightest discrepancy of assemblies with the given parameters, the system notifies developers and does not allow to start the further process of component implementation until bug fixes. Additionally, we installed Sentry, a complete error monitoring tool.
Process Optimization
In order to maintain a system in a state of high performance, we have consistently optimized business processes and infrastructure. Shared libraries and prototypes of services became the basis for the rapid implementation of new functions - we take ready-made templates and in a short time we get a working product.
Monitoring and operation
All processes are in full view. Monitoring the status of each node we provide Zabbix - a comprehensive tracking system. We got the opportunity to look into the very core of the project structure and see it compactly.
We also connected the Grafana platform, which turns dry data into a visual dashboard for the convenience of customer employees.
Stabilization and refactoring
As needed, we refactored the system - the code is simplified and becomes concise. At the same time, there is always room to grow, since regular doping of systems speeds up the site. As a result, the resource has become more friendly to search engines and users.
New architecture is the basis for growth
At the start of work, the resource had a modest potential for promotion and was not convenient enough for customers, which impeded the company's business processes. To improve the process of user interaction with the site, we almost completely updated the portal architecture and its structure, created a flexible mechanism that integrates with a large number of services and applications, thanks to our own API. Many services have been working optimally for more than a year, without requiring intervention - the number of errors in their work has decreased to almost zero.
The new site is a powerful tool for business development, with the potential for further scaling. Using the updated architecture of the web application, the project’s marketers were able to implement their range of promotional activities and increase traffic from 350 thousand unique visitors per month to more than 7 million. Moreover, after a multiple increase in audience, the portal continues to function stably.
- Obsolescence. The usability approach, adaptation to different devices, elementary appearance and structure cease to meet the needs of the audience over time.
- Technological obsolescence. Web standards and technology are constantly evolving. Changes affect both developer tools (for example, frameworks, databases, other software), and the fundamental foundations of the web. From the relatively recent - a massive transition from http to https and the abandonment of support for legacy DNS.
- Errors and crashes. Developers can imperfectly cope with their task and allow flaws. As a result of this, violations of the site may occur - starting with the fact that the buttons do not work the first time, until the systems completely fail.
Case A
client contacted us, whose web portal needed further development. At a certain point, a ceiling of 350 thousand unique visitors was reached every month. This seemed insufficient - the project clearly had prospects, and we had to find out what exactly stood in the way of further scaling the resource.
Audit
It turned out that the old Bitrix engine was not adapted to loads and scaling. Every single component of the system closely intersected and depended on each other. Constantly fixing bugs was such an excruciating task that we proposed a flexible and understandable microservice architecture. In them, each component is independent enough so that the errors inside it do not “hurt” the remaining elements of the system.
Bitrix remained the basis of the architecture - at least, authorization is tied to it, but where it was possible and promised great efficiency, we transferred the functionality to microservices. They became the cornerstone of the project.
The new combined architecture has provided us with stable, faster operation of systems and an almost complete absence of errors on some modules. It also served as the basis for the effective work of marketers. Thanks to the improved architecture, promotion specialists managed to increase the attendance of the resource by 20 times.
Microservices
We have selected modules such as file loader, search, and news feed as independent microservices. In addition to these user-friendly and obvious things, many other functional elements were implemented in the form of microservices:
- Unloading, storage and management of data from open source projects;
- Dynamic creation of RSS feeds;
- Dynamic creation of a system of blocks, layout of materials of any services into structural blocks;
- Adding additional data to service materials;
- Technical support service;
- A single catalog of various data.
In addition to all of the above, we have created many microservices for convenient work with the admin panel.
Each functional block of the site has become a fairly autonomous unit. A dedicated process is used for loading and rendering, minimizing intersection with other services.
Agree, when a user makes a payment, he will not want to wait a long time for loading the script responsible for playing the video he does not need in another part of the page. Indeed, this is what happens in monolithic systems - side functionalities sometimes interfere with the work of really important components.
We took the first step and made life easier for both users and developers, releasing more than 20 new services in a year. As a result:
- We solved the problem of scaling.
- Implemented a more efficient development process by distributed teams.
- Set up dynamic resource management for smooth and fast system operation.
Upgrading the technology stack
In parallel, we updated the technology stack. If the portal was originally based on php 5.6 and MySQL 5.6, then in the course of improving the engine, we switched it to php 7.0 and MySQL 5.7. Implemented the Yii2 framework, provided memcache caching.
Task Queue
In order to better parallelize tasks, we have transferred web workers - internal handlers - to the RabbitMQ queue. It optimizes the sequence of triggering events, which reduces the load on the system. Working with the site has become much faster and more comfortable.
Continuous Integration A
transparent and manageable development process is supported with GitLab CI. This is a truly continuous seamless development that leaves programmers and testers more time with important questions instead of patching holes.
In order to minimize errors, we introduced additional development loops. The chain consists of several application and infrastructure testing loops: pre-release, where the latest assembly testing (pre-prod), combat (prod), several test loops for testing several builds at once, as well as a loop for developers, are held. Assembly
system
At the initial stage, builds are created from the project sources. Instead of a disparate set of classes, styles, and handlers, combined entities are used - each in the shell of one executable file. Only necessary constructions are placed in the assembly for performing events on the page. This additionally provides flexibility and speed of the site.
Error monitoring
GitLab CI provides advanced features for code validation and automated testing. At the slightest discrepancy of assemblies with the given parameters, the system notifies developers and does not allow to start the further process of component implementation until bug fixes. Additionally, we installed Sentry, a complete error monitoring tool.
Process Optimization
In order to maintain a system in a state of high performance, we have consistently optimized business processes and infrastructure. Shared libraries and prototypes of services became the basis for the rapid implementation of new functions - we take ready-made templates and in a short time we get a working product.
Monitoring and operation
All processes are in full view. Monitoring the status of each node we provide Zabbix - a comprehensive tracking system. We got the opportunity to look into the very core of the project structure and see it compactly.
We also connected the Grafana platform, which turns dry data into a visual dashboard for the convenience of customer employees.
Stabilization and refactoring
As needed, we refactored the system - the code is simplified and becomes concise. At the same time, there is always room to grow, since regular doping of systems speeds up the site. As a result, the resource has become more friendly to search engines and users.
New architecture is the basis for growth
At the start of work, the resource had a modest potential for promotion and was not convenient enough for customers, which impeded the company's business processes. To improve the process of user interaction with the site, we almost completely updated the portal architecture and its structure, created a flexible mechanism that integrates with a large number of services and applications, thanks to our own API. Many services have been working optimally for more than a year, without requiring intervention - the number of errors in their work has decreased to almost zero.
The new site is a powerful tool for business development, with the potential for further scaling. Using the updated architecture of the web application, the project’s marketers were able to implement their range of promotional activities and increase traffic from 350 thousand unique visitors per month to more than 7 million. Moreover, after a multiple increase in audience, the portal continues to function stably.