{"id":527,"date":"2026-11-11T09:25:37","date_gmt":"2026-11-11T09:25:37","guid":{"rendered":"https:\/\/www.taticloud.com\/?page_id=527"},"modified":"2026-11-11T12:16:41","modified_gmt":"2026-11-11T12:16:41","slug":"blog-6-commands-to-diagnose-server-performance-issues-caused-by-low-memory","status":"publish","type":"page","link":"https:\/\/www.taticloud.com\/?page_id=527","title":{"rendered":"Blog. Linux Commands to Diagnose Server Performance Issues Caused by Low Memory"},"content":{"rendered":"\n<h1 class=\"wp-block-heading has-large-font-size\"><strong><strong>Linux Commands to Diagnose Server Performance Issues Caused by Low Memory<\/strong><\/strong><\/h1>\n\n\n\n<h1 class=\"wp-block-heading\" style=\"font-size:14px\">\ud804\uddd0 <em>A practical user guide for WordPress and LAMP administrators running on a small VPS.<\/em><\/h1>\n\n\n\n<p class=\"has-text-align-left wp-block-paragraph\"><strong>Tatiana Timonina<\/strong><\/p>\n\n\n\n<p class=\"has-small-font-size wp-block-paragraph\">November 4th, 2026 \ud804\uddd0 10 min read<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/taticloud.github.io\/taticloud-tech-writing\/lamp-stack\/\"><img loading=\"lazy\" decoding=\"async\" width=\"44\" height=\"44\" src=\"https:\/\/www.taticloud.com\/wp-content\/uploads\/2026\/11\/Docs-circular-logo.png\" alt=\"\" class=\"wp-image-1133\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Some server problems never show up as an obvious error. Your website keeps loading, WordPress still lets you log in, and everything looks relatively normal. Behind the scenes, though, your Linux server may be struggling with one of its most important resources: memory (RAM).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I ran into this on a WordPress website hosted on a DigitalOcean Ubuntu VPS. Saving changes in the WordPress admin didn&#8217;t always work, and image uploads for new blog posts were unreliable. I only connected the dots when a routine package installation during a PHP upgrade stalled. Investigating the server showed that it was running low on memory and disk space, and that the kernel&#8217;s Out-Of-Memory (OOM) Killer can terminate processes when RAM runs out.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The lesson: <strong>on a VPS, memory management matters as much as CPU performance.<\/strong> This guide walks through six commands to check whether your server is under memory pressure, identify the cause, and respond safely.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Who this guide is for:<\/strong> anyone running WordPress or a LAMP\/LEMP stack on a small Ubuntu VPS who sees slow pages, failed saves, failed uploads, or package installations that stop unexpectedly.<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Why memory problems are easy to miss<\/strong><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress, PHP, the web server, and the database all share the same limited pool of RAM. A single image upload can involve several steps at once:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>PHP receives the upload request.<\/li>\n\n\n\n<li>The image is stored temporarily.<\/li>\n\n\n\n<li>WordPress processes it and may generate additional image sizes.<\/li>\n\n\n\n<li>PHP talks to the database.<\/li>\n\n\n\n<li>The web server and PHP keep handling other visitors.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">On a VPS with limited RAM, these overlapping operations can create real memory pressure. Maintenance tasks such as package installs and upgrades add to the load. They do not necessarily cause the problem, but they can expose a limit that was already there.<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Typical warning signs<\/strong><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Changes in the WordPress admin sometimes fail to save.<\/li>\n\n\n\n<li>Image uploads fail or stop partway.<\/li>\n\n\n\n<li>Admin operations take longer than expected.<\/li>\n\n\n\n<li>Package installations hang or stop unexpectedly.<\/li>\n\n\n\n<li>Services restart or disappear without a clear error.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong><strong>Quick reference<\/strong><\/strong><\/strong><\/h2>\n\n\n<pre class=\"wp-block-code output-no-copy\"><code>#1 free -h \n'''Total, used, and available RAM, plus swap use'''\n\n#2 swapon --show\n'''Whether swap is enabled and how large it is:'''\n\n#3 ps aux --sort=-%mem | head -n 10\n'''Which processes use the most RAM'''\n\n#4 sudo journalctl -k | grep -i -E \"out of memory|killed process\"\n'''Whether the OOM Killer has terminated anything'''\n\n#5 df -h \/\n'''Free disk space (needed for swap, updates, and logs)'''\n\n#6 sudo du -xhd1 \/var\n'''Which directories consume the most disk space''' <\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Run them in this order. Commands 1 to 4 look at memory directly. Commands 5 and 6 check disk space, which matters because swap lives on disk and a full disk causes problems of its own.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Step 1. Check available memory<\/strong><\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo free -h<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is the fastest way to see how your server is doing. Look at these columns:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>total:<\/strong> the RAM installed on the server.<\/li>\n\n\n\n<li><strong>used:<\/strong> memory currently in use.<\/li>\n\n\n\n<li><strong>available:<\/strong> the estimate of RAM that can be given to new processes without swapping. <strong>This is the number to watch.<\/strong><\/li>\n\n\n\n<li><strong>Swap:<\/strong> whether swap exists and how much of it is in use.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong><em>What to look for:<\/em><\/strong><em> consistently low available memory signals memory pressure. In my case, the server had 961 MiB total but only about 45 to 48 MiB available, and no swap. That is a server with no breathing room.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>Note:<\/em><\/strong><em> don&#8217;t judge by the &#8220;free&#8221; column alone. Linux uses spare RAM for caching, so &#8220;free&#8221; is often small on a healthy system. &#8220;Available&#8221; is the honest figure.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Step 2. Check whether swap is enabled<\/strong><\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo swapon --show<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the command prints nothing, there is no active swap. If it lists a file or partition, swap is enabled, and you can see its size.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why swap matters:<\/strong> swap lets Linux use disk space as overflow when physical RAM runs low.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>A safety buffer.<\/strong> Short memory spikes (an image upload, a backup, a package upgrade) can be absorbed instead of triggering the OOM Killer.<\/li>\n\n\n\n<li><strong>Fewer abrupt terminations.<\/strong> Processes are less likely to be killed mid-task.<\/li>\n\n\n\n<li><strong>Cheap insurance.<\/strong> On a small VPS, a modest swap file costs only some disk space.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What swap is not:<\/strong> disk is much slower than RAM. Heavy, constant swapping makes a server sluggish. Treat swap as a safety net, not a substitute for adequate RAM.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Step 3. Identify the processes consuming RAM<\/strong><\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">ps aux --sort=-%mem | head -n 10<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This lists the ten processes using the most memory. Check the <strong>%MEM<\/strong> and <strong>RSS<\/strong> columns (RSS is the actual memory in use, in KB) and the <strong>COMMAND<\/strong> column.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On a WordPress server, the usual suspects are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apache or Nginx worker processes<\/li>\n\n\n\n<li>PHP-FPM workers (or Apache with mod_php)<\/li>\n\n\n\n<li>MySQL or MariaDB<\/li>\n\n\n\n<li>Background tasks and other system services<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong><em>What to look for:<\/em><\/strong><em> many copies of the same process (for example, a long list of PHP-FPM or Apache workers) or a single process using a very large share of RAM. These point to settings that need tuning, covered in the best practices below.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Step 4. Check whether the OOM Killer has acted<\/strong><\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo journalctl -k | grep -i -E \"out of memory|killed process\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the server truly runs out of memory, the kernel&#8217;s OOM Killer terminates a process to keep the system alive. This command searches the kernel log for those events.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Matches found:<\/strong> the server has run out of memory. The log line names the killed process, which often explains the failed save or upload you saw.<\/li>\n\n\n\n<li><strong>No output:<\/strong> no OOM events are in the retained logs. That is good news, but it is not proof, because old journal entries may have been removed.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Step 5. Check available disk space<\/strong><\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo df -h \/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Memory and disk are connected. You need free disk space to create a swap file, install updates, and store logs. Look at <strong>Avail<\/strong> and <strong>Use%<\/strong>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong><em>What to look for:<\/em><\/strong><em> a root filesystem above roughly 85 to 90 percent full. In my case, the disk was 89 percent used with only 1.1 GB free, which left little room for anything else.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Step 6. Find what is using the disk<\/strong><\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo du -xhd1 \/var<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This shows the size of each directory directly under \/var, where logs, caches, databases, and website files typically live. The -x option keeps the scan on one filesystem, and 2&gt;\/dev\/null (optional) hides permission noise.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two related checks are worth running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo journalctl --disk-usage<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo dpkg --audit<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first shows how much space system logs use. In my case, the journal alone took about 928 MB. The second reports any packages left in an incomplete state, which helps if an install or upgrade stalls.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong><em>Important:<\/em><\/strong><em> never delete files directly from \/var\/lib or \/var\/www to free space. These directories can hold databases, website files, and package-management data.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><strong>Recover disk space safely<\/strong><\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If logs and caches are the problem, clean them with the tools built for the job:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo journalctl --rotate<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo journalctl --vacuum-size=100M<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo apt clean<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">df -h \/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In my case, this recovered about 1 GB, taking free space from 1.1 GB to 2.1 GB.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong><em>Before you vacuum:<\/em><\/strong><em> this removes historical logs. If you need them for auditing or incident investigation, export or back them up first.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Add emergency swap space<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If swapon &#8211;show prints nothing and you have enough free disk, create a swap file. This example creates a 512 MB file, which suits a small VPS. Choose a size that fits your RAM and disk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Check that no swap file already exists<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">ls -lh \/swapfile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. <strong>Allocate the file<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo fallocate -l 512M \/swapfile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. <strong>Set secure permissions<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo chmod 600 \/swapfile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>4. Format it as swap<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo mkswap \/swapfile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>5. Enable it<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo swapon \/swapfile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>6. Verify<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">free -h<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">swapon --show<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Make swap persistent after reboot<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, check whether an entry already exists:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">grep -n \"\/swapfile\" \/etc\/fstab<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If nothing is returned, add exactly one entry:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">echo \"\/swapfile none swap sw 0 0\" | sudo tee -a \/etc\/fstab\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This makes Ubuntu activate the swap file at startup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Key points to remember<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Watch &#8220;available,&#8221; not &#8220;free.&#8221;<\/strong> Available memory is the real indicator of pressure.<\/li>\n\n\n\n<li><strong>Slow or failing WordPress operations can be a memory problem,<\/strong> not only a WordPress or plugin problem.<\/li>\n\n\n\n<li><strong>No swap means no buffer.<\/strong> A small swap file can mean the difference between a brief slowdown and a killed process.<\/li>\n\n\n\n<li><strong>Swap is a safety net, not extra RAM.<\/strong> Constant heavy swapping means you need to tune or upgrade.<\/li>\n\n\n\n<li><strong>Disk and memory are linked.<\/strong> A nearly full disk limits swap, updates, and logging.<\/li>\n\n\n\n<li><strong>Clean up with the right tools.<\/strong> Use journal and APT commands rather than deleting files by hand.<\/li>\n\n\n\n<li><strong>Logs are evidence.<\/strong> Export them before vacuuming if you may need them later.<\/li>\n\n\n\n<li><strong>Empty OOM results are not a guarantee.<\/strong> Old log entries may already be gone.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Best practices for VPS memory<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Tune PHP-FPM.<\/strong> Set pm.max_children to a value your RAM can actually support. Too many workers commonly cause memory exhaustion.<\/li>\n\n\n\n<li><strong>Disable unnecessary PHP extensions<\/strong> to reduce per-process memory.<\/li>\n\n\n\n<li><strong>Configure OPcache appropriately<\/strong> so PHP does not recompile scripts on every request.<\/li>\n\n\n\n<li><strong>Review MySQL\/MariaDB memory settings,<\/strong> since the defaults may not suit a small server.<\/li>\n\n\n\n<li><strong>Monitor regularly.<\/strong> Run free -h and df -h \/ as part of routine maintenance, and check the heaviest processes if the server feels slow.<\/li>\n\n\n\n<li><strong>Set journal retention limits<\/strong> so logs do not quietly fill the disk again.<\/li>\n\n\n\n<li><strong>Back up before maintenance.<\/strong> Take site, database, and configuration backups before upgrades, and schedule a maintenance window for production changes.<\/li>\n\n\n\n<li><strong>Add swap as a buffer,<\/strong> then keep monitoring.<\/li>\n\n\n\n<li><strong>Upgrade your VPS RAM when the workload genuinely requires it.<\/strong> Tuning and swap have limits. If memory pressure continues after you have optimized, a larger plan is the right fix.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Memory trouble on a VPS is easy to mistake for a WordPress, plugin, or package problem. These six commands give you a quick, safe way to tell the difference: check RAM, check swap, find the heaviest processes, look for OOM events, and confirm you have the disk space to work with. Make them part of your routine maintenance, and you will catch memory pressure before it turns into failed uploads or interrupted upgrades.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux Commands to Diagnose Server Performance Issues Caused by Low Memory \ud804\uddd0 A practical user guide for WordPress and LAMP administrators running on a small VPS. November 4th, 2026 \ud804\uddd0 10 min read Introduction Some server problems never show up as an obvious error. Your website keeps loading, WordPress still lets you log in, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-527","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.taticloud.com\/index.php?rest_route=\/wp\/v2\/pages\/527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.taticloud.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.taticloud.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.taticloud.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.taticloud.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=527"}],"version-history":[{"count":11,"href":"https:\/\/www.taticloud.com\/index.php?rest_route=\/wp\/v2\/pages\/527\/revisions"}],"predecessor-version":[{"id":1143,"href":"https:\/\/www.taticloud.com\/index.php?rest_route=\/wp\/v2\/pages\/527\/revisions\/1143"}],"wp:attachment":[{"href":"https:\/\/www.taticloud.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}