We thoroughly reviewed the documentation from the KVS vendor and concluded that the possibility of horizontal scaling was not initially intended. All service components are located on one server, which is convenient for deployment but greatly reduces flexibility.
The client usually rented a bare-metal server for a new project, which initially led to significant underutilization of capacities, and then to the impossibility of increasing them in case of a sudden increase in load.
In the first iteration, we considered the possibility of deploying nodes as monolithic self-sufficient nodes on virtual machines. Subsequently, we managed to find a way to divide and automate the deployment of the service on several independent virtual machines:
- Frontend (nginx + specific client-side PHP code)
- Administration module (video moderation, conversion, and other tasks)
- Database
- Sphinx node (search engine)
By implementing MariaDB MaxScale, we were able to achieve effective horizontal scaling of the database, dividing the intensive load on reading and writing across different nodes. Other architectural elements were also modified to allow for quick horizontal scaling of the number of nodes.
All new projects are now fully described using terraform and ansible, which allows deploying the entire infrastructure for a new project from scratch within a few minutes, adding or reducing the number of necessary nodes. Reliability also increased due to geo-redundancy of critical elements. The client gained the ability to start with a minimal-sized virtual infrastructure, increasing capacity as load grows. This led to a 3.4-fold reduction in the average cost of maintaining infrastructure at the start compared to previous indicators.
All IaC code and documentation on scaling were handed over to the client.