/wp-admin/admin-ajax.php issue - high CPU usage

Genesis

Administrator
Staff member
This is not overly serious, but serious enough for me to be concerned. I've just picked up on an /wp-admin/admin-ajax.php issue in my Word Press website that creates high CPU usage. I Googled the problem, and the solution seems to be to fiddle with the code of the theme by disabling the WP heartbeat in the backend. Feedback from users with this problem seems to vary. Quite a number had error problems as a consequence of this coding modification as apparently the WP heartbeat feature is important for the functionality of some of the plugins. The ultimate solution overall seems to be to drop the theme and use another theme. Which is what I'm considering right now.

Am wondering whether any one else has encountered this problem?
 

imama

New member
Well that happened with me so after some research i decreased the "Heartbeat" time Here is how
Change the rate of the default Heartbeat requests

First make a backup copy of this file:

/wp-includes/js/heartbeat.min.js

Now it can get a bit tricky due to this JavaScript file being minimized, but essentially you want to find the 3 separate cases for request activity, 15 seconds, 30 seconds, and 60 seconds and increase the time of all of these.

In all the examples below, the ...'s indicate that there is other code you don't need to edit in-between the parts you do need to edit.

15 Second requests

To extend the default behavior of having a Heartbeat request every 15 seconds, you would look for this code:

B.mainInterval<15?B.mainInterval=15:...case 15:

Change it to something like 120 to extend Hearbeat requests out to 2 minutes by default:

B.mainInterval<120?B.mainInterval=120:...case 120:

30 Second requests

To extend the behavior of having a Heartbeat request every 30 seconds, you would look for this code:

case 30:...30,b=1>b||b>30?30:

Change it to something like 300 to extend Hearbeat requests out to 5 minutes:

case 300:...300,b=1>b||b>300?300:

60 Second requests

To extend the behavior of having a Heartbeat request every 60 seconds, you would look for this code:

B.mainInterval>60&&(B.mainInterval=60))...case 60:...mainInterval:60

Change it to something like 600 to extend Hearbeat requests out to 10 minutes:

B.mainInterval>600&&(B.mainInterval=600))...case 600:...mainInterval:600

I got this from some help forum that i don't remember