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.
Log in to WHM.
Navigate to Module Configuration > Server Information.
Review the Memory section to see the current usage versus the total available memory.
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.
Access the Terminal or SSH into the server as root.
Run the command
toporhtopto view a real-time list of processes.Identify processes with high
%MEMvalues.
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.
Check the number of active PHP processes using
ps aux | grep php.If a specific domain is causing the spike, check the Resource Usage for that specific account in WHM.
Review the Apache Status (if enabled) to see which scripts are running longest.
Database Processes
If MySQL or MariaDB is the primary consumer:
Log in to the server via SSH.
Run the command
mysqladmin -u root -p processlistto see active queries.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.
Run
systemctl status [service_name]to check the status of specific services.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
In WHM, navigate to Software > MultiPHP Manager.
Select the affected domain and click Configure.
Adjust the
memory_limitto a reasonable value for the specific application (e.g., 256M or 512M) rather than an excessively high value.Ensure that
max_execution_timeis not set so high that it allows "zombie" processes to hang in memory.
Optimize MySQL/MariaDB
If MySQL is consuming excessive memory, it may be due to an oversized
innodb_buffer_pool_size.Use a tool like MySQLTuner to analyze your configuration.
Adjust the configuration in
/etc/my.cnfor/etc/mysql/grub.confto better align with your physical RAM.
Limit Resource Usage per Account
In WHM, navigate to Account Functions > Modify Account.
Select the account experiencing high usage.
If using a CloudLinux environment, use LVE Manager to set strict memory limits for that specific user.
Confirm the result
The
toporhtopcommand 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).
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.
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 %MEMcommand and the results of amysql_query_logif database issues are suspected.
