If you find your VPS memory usage spikes at certain times of the day, you can use a benchmarking tool to simulate the high-traffic environment. Once running, you can then check memory processes to determine the cause of the problem.
This article explains how to use the ab command line benchmarking tool on your VPS.
View the following link for further details on the ab command.
To use this tool:
- Log into your server via SSH.
- Run the following command:
[server]$ ab -n 1000 -c 20 https://www.example.com/index.html
This command creates 1000 connections to https://www.example.com/index.html, limiting itself to 20 concurrent connections.
Viewing your processes while testing
While the ab command is running, open 2 more tabs in your terminal to observe server processes.
- In the first window, run top -c. Then, sort by memory (Shift + M).
- In the second window, run free -m (or watch free -m).
These commands are effective at profiling your sites and checking to see if caching is working. You can repeat this process for each of your domains to see which ones most affect your memory usage so you know where to optimize.