N
N
Nexuus2020-12-02 13:22:43
Scalability
Nexuus, 2020-12-02 13:22:43

Horizontal scaling. Where to begin?

Good afternoon.
I am working on a project in PHP. This is a monolith. Everything revolves on one server: Intel Core i7, 32 GB RAM, 500 GB SSD. In principle, everything is fine and the load is still holding. But I'm going to jump ahead a bit and understand how to scale correctly.
The project uses the following technologies: PHP Yii2, there is memcached, sessions are stored in redis, queues are also used, which also work through redis.
The first thing that comes to mind is to move the database to a separate server. Then install a balancer and distribute incoming requests to several servers. What to do with memcached and redis, put them on a separate server too?
Here I want to understand how to choose the right server for these tasks? How to calculate what kind of processor, memory, etc. you need. I would like to make a reliable system and at the same time not scatter resources, tk. the budget is very limited.
Thanks in advance for your replies!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Gornostaev, 2020-12-02
@sergey-gornostaev

You have to start with measurements. Collect an execution profile, look at the hottest places, evaluate whether it is possible to somehow parallelize these places, if so, how, and what costs may arise. Everything else depends on the answers to these questions.

S
Sanes, 2020-12-02
@Sanes

If there is a large load on the database, then replication can be done.
Your application must support multiple databases with division into operations.
This is where you can start.

R
rPman, 2020-12-02
@rPman

All of the above will help you with horizontal scaling... but almost certainly, unfortunately, linearly, i.e. load increased by 2 times - double the number of servers.
---------- do not take it as a run over ---------------
the following can be said in one word - rewrite;)
First of all, I would get rid of the root problems that almost certainly you are sitting because of the basis of Yii - http rest technology (by the way, not a fact) and building a view on the server.
If you start moving everything related to displaying and building appearance to the client, you will almost certainly increase the speed by an order of magnitude, postponing the need for scaling for a long time, but then it’s not clear why you need Yii :) i.e. instead of developing an application on a server in php, you'd better write everything related to the user interface in javascript, and let the server handle the logic and keep the database. Those. take the view out (in fact, your view will turn into just a data stream in the form of json and transfer the ui to client js).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question