Skip to main content

How to Troubleshoot High Memory Usage on a cPanel Server

Identify and resolve high memory consumption on a cPanel server to ensure optimal performance and stability. This guide is intended for server administrators using WHM to monitor and manage server resources.

Identify and resolve high memory consumption on a cPanel server to ensure optimal performance and stability. This guide is intended for server administrators using WHM to monitor and manage server resources.

Before you begin

You will need:

  • Root access to the server via WHM

  • A clear understanding of the server's current resource limits and usage patterns

Check current memory usage and identify the culprit

To resolve high memory usage, you must first identify which processes or services are consuming the most resources.

  1. Log in to WHM.

  2. Navigate to Module Configuration > Server Information.

  3. Review the Memory section to see the current usage versus the total available memory.

  4. If the memory usage is consistently high, navigate to Home > Server Information (or use the Resource Usage tool if available) to identify specific accounts or processes.

  5. Access the Terminal or SSH into the server as root.

  6. Run the command top or htop to view a real-time list of processes.

  7. Identify processes with high %MEM values.

Note: The top command provides a real-time view of system resources, while htop provides a more interactive, color-coded interface (if installed).

Investigate specific high-usage areas

If the high memory usage is tied to specific services, perform the following checks:

Web Server and PHP Processes

If Apache or Nginx processes are consuming excessive memory, it is often due to a high number of concurrent PHP scripts.

  1. Check the number of active PHP processes using ps aux | grep php.

  2. If a specific domain is causing the spike, check the Resource Usage for that specific account in WHM.

  3. Review the Apache Status (if enabled) to see which scripts are running longest.

Database Processes

If MySQL or MariaDB is the primary consumer:

  1. Log in to the server via SSH.

  2. Run the command mysqladmin -u root -p processlist to see active queries.

  3. Identify queries that are running for an extended period or are poorly optimized.

System Services

Check if background services (such as ClamAV, Exim, or others) are consuming more memory than expected.

  1. Run systemctl status [service_name] to check the status of specific services.

  2. Review the service's configuration files to ensure limits are correctly set.

Resolve common causes of high memory usage

Once the source of the high memory usage is identified, apply the following fixes:

Optimize PHP Configuration

  1. In WHM, navigate to Software > MultiPHP Manager.

  2. Select the affected domain and click Configure.

  3. Adjust the memory_limit to a reasonable value for the specific application (e.g., 256M or 512M) rather than an excessively high value.

  4. Ensure that max_execution_time is not set so high that it allows "zombie" processes to hang in memory.

Optimize MySQL/MariaDB

  1. If MySQL is consuming excessive memory, it may be due to an oversized innodb_buffer_pool_size.

  2. Use a tool like MySQLTuner to analyze your configuration.

  3. Adjust the configuration in /etc/my.cnf or /etc/mysql/grub.conf to better align with your physical RAM.

Limit Resource Usage per Account

  1. In WHM, navigate to Account Functions > Modify Account.

  2. Select the account experiencing high usage.

  3. If using a CloudLinux environment, use LVE Manager to set strict memory limits for that specific user.

Confirm the result

  • The top or htop command shows a significant decrease in memory usage by the identified problematic processes.

  • The server's Server Information page shows a stable memory overhead.

  • The system no longer triggers "Out of Memory" (OOM) errors or service restarts.

If the server remains unstable or unresponsive

If memory usage remains high despite optimizations, the server may be over-provisioned (too many accounts for the available physical RAM).

  1. Identify the specific account: Use the Resource Usage tool in WHM to see if one account is consuming a disproportionate amount of the server's resources.

  2. Contact Hostek Support: If you cannot identify the cause or if the hardware appears to be under-performing, contact Hostek support with the output of the top -o %MEM command and the results of a mysql_query_log if database issues are suspected.

Did this answer your question?