The post has been translated automatically. Original language: Russian
One of the most common questions after starting a new project sounds very simple.:
"How much memory should I allocate to the VM?"
There is no universal answer. The same volume may be excessive for a corporate website and insufficient for a database.
Therefore, after some time after launch, it is better not to guess, but to see how the system uses the allocated resources.
There are several signs that are really worth paying attention to.
The first sign is that the memory is almost always fully occupied.
If there is very little free memory left, and the system regularly starts using the swap partition, this is already a reason to figure out the reasons. It is not always necessary to immediately increase the amount of RAM, but you should not ignore this situation.
The second sign is that the response time has increased significantly after the load has increased.
For example, a website runs fast in the morning, but starts to slow down in the afternoon when more visitors arrive. Sometimes the reason turns out to be in the application or database, but lack of memory is also quite common.
The third sign is that the system itself has changed in recent months.
New services have been added.
The database has increased.
Additional modules have been added.
If the VM has started to perform more tasks, its initial configuration may no longer match the actual load.
There is also a reverse situation.
Sometimes the memory is increased immediately after the first signs of slowing down, without checking the rest of the indicators.
In practice, this does not always help.
If the problem is related to a slow disk, an unsuccessful database query, or an error in the application, the extra gigabytes won't change anything.
That is why it is better to make any changes after analyzing the monitoring, rather than feeling it.
Modern cloud platforms allow you to increase the amount of memory quickly enough.
It is much more difficult to determine the moment when it is really necessary.
If you focus not on assumptions, but on the actual performance of the system, the solution usually turns out to be much more accurate.
Иногда возникает странная ситуация.
Несколько пользователей говорят, что сайт открывается медленно. При этом остальные продолжают работать без каких-либо проблем.
Первая мысль обычно одна — проблема на сервере.
Но на практике причина может оказаться совсем в другом месте.
Почему так бывает
Путь от пользователя до сайта состоит не только из самого сервера.
На скорость могут влиять интернет-провайдер, домашний роутер, корпоративная сеть, качество мобильного соединения или временные проблемы на отдельных участках маршрута.
Именно поэтому два человека, находящиеся в разных городах или использующие разных провайдеров, иногда получают совершенно разную скорость доступа к одному и тому же сайту.
С чего лучше начать проверку
Если жалоба поступила только от нескольких пользователей, сначала полезно собрать немного дополнительной информации.
- Из какого города или страны открывается сайт.
- Используется домашний интернет, корпоративная сеть или мобильная связь.
- Проблема наблюдается постоянно или возникает периодически.
- Повторяется ли она у других пользователей.
Эти простые вопросы часто помогают значительно быстрее определить направление поиска.
Почему это экономит время
Если сразу начать изменять настройки сервера, можно потратить несколько часов и не получить результата.
Иногда проблема вообще находится за пределами инфраструктуры сайта и никак не связана с его производительностью.
Поэтому опытные специалисты сначала собирают факты, а уже потом принимают решение, где искать источник проблемы.
Вместо вывода
Жалоба на медленную работу сайта еще не означает, что проблема находится на сервере.
Чем раньше удается понять, затрагивает проблема всех пользователей или только часть из них, тем быстрее находится настоящее решение.