Main Content

It’s not WordPress’ Heartbeat and cron killing your server.

WordPress Apache LogoA few days ago I wrote about how WordPress’ Heartbeat and cron jobs were killing my server. Turns out I was wrong.

John Havlik connected with me and helped me troubleshoot some things. Turns out that the real issue is the server settings.

Now, I’m not going to tell you what to do to optimize your server, but I will tell you the things I did and you can choose to try them at your own risk.

Timeout

We changed the timeout setting from 60 to 10 in Apache.

This setting defines the number of seconds the server waits for a script or asset to respond. If one script or asset is not responding, the site will wait 60 seconds before it kills it.

If you have a bunch of people visiting your site, and your sever is trying to load that one script many times, it’s going to continue to wait 60 seconds per person. This eats up a lot of server resources because even if the visitor leaves, the server is still waiting on that script to respond.

Timing out after 10 seconds gives the server resources back to the server much faster.

Changed the prefork MPM settings.

Not exactly sure what these do, but again we are adjusting the settings to help ensure the server gets back as many resources as it can.

We updated them to:

StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 200
MaxRequestsPerChild 10000

WP Super Cache

I also made sure that WP Super Cache was working with the best possible settings. I always rely on the instructions that TigerTech gives me as they seem to work  great.

Did it work?

I think so. I’ve re-enabled everything I disabled before and my server has been very happy for the past two days. However, I did have an issue when traffic spiked today. So my issue seems to be related to traffic spikes. Sadly it’s not much of a spike and when I restarted httpd everything went back to normal.

Overall, things are looking up and the CPU is extremely low. I won’t be able to give a definitive answer for a few weeks, but all signs are looking good.  It may not be perfect yet, but it’s far better than it was.

At the end of the day, blaming WordPress is easy to do. We do this because we understand WordPress more than we do our server. However, it’s those server settings that make a huge impact.

Advertisements

1 Response

  1. steeleweed says:

    Thank you – having CPU issues on some hosts, not others. Maybe some hosts adjusted to WP 3.6 and some didn’t.

Leave a Reply