> ## Documentation Index
> Fetch the complete documentation index at: https://docs.digitalfyre.com/llms.txt
> Use this file to discover all available pages before exploring further.

# High CPU or Memory Usage

If your VPS is slow or unresponsive, or showing high resource usage in the [Server Statistics](/vps/client-portal/server-statistics), use the steps below to identify the cause.

## Identifying the Problem

### CPU

```bash lines theme={"theme":{"light":"light-plus","dark":"ayu-dark"}}
# Top processes by CPU usage
top -bn1 -o %CPU | head -20

# Alternative using ps
ps aux --sort=-%cpu | head -15
```

Look for processes consuming a disproportionate amount of CPU. Common causes include runaway scripts, unoptimised database queries, bot traffic, and compromised processes such as crypto miners.

### Memory

```bash lines theme={"theme":{"light":"light-plus","dark":"ayu-dark"}}
# Memory overview
free -h

# Top processes by memory
ps aux --sort=-%mem | head -15
```

In the `free -h` output, focus on **available** memory and **swap used**. If swap usage is significant, your server is under genuine memory pressure.

<Info>
  Linux uses available memory for disk caching, so high memory usage is not always a problem. The concern is when available memory is very low and swap is being used heavily.
</Info>

### Disk I/O

High I/O wait can appear as high CPU load:

```bash lines theme={"theme":{"light":"light-plus","dark":"ayu-dark"}}
# Check iowait (the "wa" column)
top -bn1 | head -5
```

A high `%iowait` value means the CPU is waiting on disk operations rather than doing useful work.

## Common Causes and Fixes

**Runaway process**

```bash lines theme={"theme":{"light":"light-plus","dark":"ayu-dark"}}
# Identify and kill the process
top
kill -9 PID
```

Check application logs, cron jobs, and scripts for the root cause.

**Database (MySQL / MariaDB)**

```bash lines theme={"theme":{"light":"light-plus","dark":"ayu-dark"}}
# Check active queries
mysql -e "SHOW FULL PROCESSLIST;"
```

Common fixes: add indexes to frequently queried tables, optimise slow queries, tune the InnoDB buffer pool size.

**Web server under load**

```bash lines theme={"theme":{"light":"light-plus","dark":"ayu-dark"}}
# Check active connections
ss -s

# Check access logs for spikes
tail -f /var/log/nginx/access.log
```

Consider rate limiting, caching, or blocking abusive IPs if traffic is from bots or an attack.

**OOM killer events**

When Linux runs out of memory, the kernel terminates processes to free RAM. Check if this has happened:

```bash lines theme={"theme":{"light":"light-plus","dark":"ayu-dark"}}
dmesg | grep -i oom
```

If OOM kills are occurring regularly, reduce your application's memory footprint or upgrade your plan.

## When to Upgrade

If your server consistently runs above 80% CPU or memory usage under normal load after optimisation, the workload has outgrown the plan. See [Upgrading Your VPS](/vps/billing/upgrading).
