My journey down running my own server has hit a snag. It seems my machine likes to spike to 100% CPU and get stuck there until I force restart it. So I’ve been digging.
One of the ideas I came across was disabling WordPress’ heartbeat. It sounds horrible, but I’m not really using it for much and it runs every 15 seconds!
The purpose of this API is to simulate bidirectional connection between the browser and the server. Initially it will be used for autosave, post locking and log-in expiration warning while a user is writing or editing.
The idea is to have a relatively simple API that sends XHR requests to the server every 15 seconds and triggers events (or callbacks) on receiving data. Other components would be able to “hitch a ride” or get notified about another user’s activities.
In the future this can be used to block simultaneous editing of widgets and menus or any other tasks that require regular updates from the server.
I found out that the heartbeat is calling admin-ajax.php quite often causing massive CPU usage, or so markomedia tells me. So I’m giving it a try.
The nice thing about the code markomedia provides is that it keeps the heartbeat for auto saving posts while disabling other functionality.
I’m also looking into other ideas such as disabling the cron. I keep reading things that say it’s out of control as well. This is next on my list of things to try.
I really wish WordPress would work out some of these issues. As they continue to take over the web, hosting WordPress is going to become more and more difficult as things like this hide in the background.