Hjälpcentral

Diagnosing high CPU or memory usage Skriv ut

  • cpu, memory, performance, troubleshooting
  • 0

Overview

A Pod that feels slow, or that is consistently pegged at 100% CPU or out of memory, needs investigation before it affects your users. This article shows how to find the culprit.

Before you begin

  • Root or sudo access.
  • Note what changed recently — a new deployment, a traffic spike, or a new plugin.

Steps

  1. Get a quick overview with top or htop:

bash top

Press M to sort by memory or P by CPU.

  1. Find the heaviest processes non-interactively:

bash ps aux --sort=-%cpu | head ps aux --sort=-%mem | head

  1. Check memory and swap:

bash free -h

If swap is heavily used and available memory is near zero, you are memory-constrained.

  1. Check load average and CPU count:

bash uptime nproc

A load average higher than your CPU count means processes are queueing.

  1. Investigate the top process. For example, for a web service:

bash systemctl status nginx journalctl -u php8.2-fpm --since "1 hour ago"

For a database, look at slow queries rather than assuming the database is at fault.

  1. Look for runaways or malware. Unexpected processes consuming CPU (especially miners) are a red flag:

bash sudo ps aux | grep -v '\[' sudo ss -tp

  1. Reduce pressure. Common fixes:
    • Tune the number of PHP-FPM or worker processes.
    • Enable caching (OPcache, Redis) for web applications.
    • Reschedule heavy cron jobs to off-peak times.
    • Add swap space as a safety net.
  2. Upgrade if it is genuine demand. If the workload has simply outgrown the Pod, resize to a larger CPU Pod from the ALYPOD Console.

Troubleshooting

  • Problem: CPU is high but the top process keeps changing. Solution: Use pidstat 1 or atop to see which processes spike over time.
  • Problem: The OOM killer is terminating services. Solution: Check dmesg | grep -i oom, increase memory, or fix the leak; add swap as a temporary buffer.

Related articles

  • [Disk is full: how to free space]
  • [My website shows a 500 error]
  • [Protecting your server against malware]

Hjälpte svaret dig?

«Tillbaka