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.
После изменений на сайте многие первым делом проверяют журналы ошибок.
Если новых записей нет, кажется, что обновление прошло успешно.
На практике это далеко не всегда так.
Некоторые проблемы вообще не попадают в журналы, но при этом напрямую влияют на посетителей.
Какие ситуации встречаются чаще всего
Представьте, что форма обратной связи перестала отправлять письма.
Сайт открывается без ошибок, страницы загружаются быстро, а журналы приложений остаются пустыми.
Посетитель уверен, что заявка отправлена, а владелец сайта узнает о проблеме только спустя несколько дней.
Похожая ситуация может возникнуть с личным кабинетом, поиском по сайту или загрузкой файлов.
Почему так происходит
Не каждая ошибка приводит к аварийному завершению программы.
Иногда приложение продолжает работать, но отдельная функция перестает выполнять свою задачу.
С точки зрения сервера все выглядит нормально, а пользователь уже столкнулся с проблемой.
Что помогает обнаружить такие случаи
Полезно время от времени выполнять несколько привычных действий так, словно вы обычный посетитель.
- Отправить тестовую заявку.
- Проверить получение письма.
- Войти в личный кабинет.
- Загрузить небольшой файл, если такая возможность предусмотрена.
- Открыть сайт с телефона.
Такая проверка занимает всего несколько минут, но позволяет обнаружить проблемы, которые никогда не появятся в журнале ошибок.
Маленькая привычка, которая экономит время
После любого обновления полезно проверять не только техническое состояние сервера, но и несколько основных сценариев использования сайта.
Именно они отражают то, что действительно видят посетители.
Вместо вывода
Отсутствие сообщений об ошибках — хороший признак, но не доказательство того, что все работает идеально.
Самый надежный способ убедиться в результате — иногда посмотреть на сайт глазами обычного пользователя.