Fix Apache High CPU Usage (Complete 2026 Guide for Beginners & Experts)

If your server is slowing down, websites are loading late, or you’re constantly seeing spikes in load, there’s a high chance that Apache is consuming excessive CPU resources.

This is one of the most common issues on VPS, cloud servers, and cPanel hosting environments.

In this guide, you’ll learn:

  • Why Apache CPU usage becomes high
  • How to identify the root cause
  • Step-by-step fixes that actually work
  • Pro tips to permanently reduce CPU usage

🚨 Signs of High Apache CPU Usage

Before fixing, confirm the issue:

  • Server load is always above 2–5
  • Website response time is slow
  • Frequent 503 / 500 errors
  • SSH becomes slow or unresponsive
  • top command shows Apache using high CPU

Run this command:

top

Look for processes like:

httpd
apache2

If they are consuming 80%–100% CPU, you have a problem.


🔍 Step 1: Identify the Root Cause

Run:

ps aux --sort=-%cpu | head

Also:

netstat -anp | grep :80 | wc -l

This tells you:

  • Which processes are consuming CPU
  • Number of active connections

Common Causes:

  • Too many concurrent requests
  • Bad bots or DDoS
  • Poor Apache configuration
  • Heavy WordPress plugins
  • No caching enabled

⚙️ Step 2: Optimize Apache Configuration

Edit Apache config:

nano /etc/apache2/apache2.conf

Or (CentOS):

nano /etc/httpd/conf/httpd.conf

Optimize These Settings:

StartServers          2
MinSpareServers       2
MaxSpareServers       5
MaxRequestWorkers     150
MaxConnectionsPerChild 3000

👉 Reduce MaxRequestWorkers if CPU is high.

Restart Apache:

systemctl restart apache2

🚀 Step 3: Enable KeepAlive Optimization

Find:

KeepAlive On

Modify:

KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 2

👉 Lower timeout = less CPU usage


🔥 Step 4: Enable GZIP Compression

a2enmod deflate
systemctl restart apache2

Add:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript

This reduces bandwidth and CPU load.


🛡️ Step 5: Block Bad Bots & Spam Traffic

Install:

apt install apache2-utils

Use .htaccess:

<RequireAll>
  Require all granted
  Require not ip 192.168.1.1
</RequireAll>

Or block user agents:

SetEnvIfNoCase User-Agent "badbot" bad_bot
Deny from env=bad_bot

⚡ Step 6: Enable Apache Caching

Install:

a2enmod cache
a2enmod cache_disk
systemctl restart apache2

Add:

CacheEnable disk /
CacheRoot "/var/cache/apache2/mod_cache_disk"

💡 Step 7: Use a Reverse Proxy (Highly Recommended)

Apache alone is heavy.

👉 Best solution:

  • Use Nginx + Apache (hybrid setup)

This reduces CPU usage by up to 70%.

👉 Recommended hosting setup:

The Ultimate Managed Hosting Platform

⚙️ Step 8: Optimize WordPress (If Applicable)

If you are running WordPress:

  • Remove heavy plugins
  • Use caching plugin
  • Optimize database

Recommended Hosting:


🔎 Step 9: Monitor Logs for Issues

Check error logs:

tail -f /var/log/apache2/error.log

Look for:

  • Repeated requests
  • PHP errors
  • Bot attacks

📊 Step 10: Use Cloudflare (Free Protection)

Cloudflare helps:

  • Block bots
  • Reduce server load
  • Improve speed

🔥 Bonus: Quick Fix Commands

Restart Apache:

systemctl restart apache2

Kill high CPU process:

kill -9 PID

🚀 Advanced Optimization (Pro Level)

  • Switch MPM to Event:
a2dismod mpm_prefork
a2enmod mpm_event
  • Use HTTP/2:
a2enmod http2

📌 Final Thoughts

Apache high CPU usage is not just a server issue — it directly impacts your:

  • SEO rankings
  • User experience
  • Revenue

If you fix it properly, you can:

  • Reduce server cost
  • Improve performance
  • Handle more traffic

💰 Recommended Setup (Best Performance)

For long-term stability:

👉 High-performance VPS:

The Ultimate Managed Hosting Platform

👉 Managed hosting:


❓ FAQs

Why is Apache using 100% CPU?

Due to high traffic, poor configuration, or bot attacks.

Is Nginx better than Apache?

Yes, for high traffic websites.

Can caching reduce CPU?

Yes, drastically.


🏁 Conclusion

Fixing Apache CPU usage is about:

  • Optimization
  • Monitoring
  • Smart architecture

Follow this guide and your server will run fast, stable, and scalable.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *