The following article provides information on how to diagnose and troubleshoot high server usage from admin-ajax.php. By itself, the admin-ajax file has practical applications for your website. It's often involved with plugins, auto-saving, session management, and notifications.
However, if left unmanaged, the file may eventually start using up unnecessary CPU and load on your server. This can potentially result in a slower site or resource overages.
STATEMENT OF SUPPORT:
Please keep in mind that troubleshooting the configuration/functionality of third-party applications is not covered by our statement of support. These resources were provided as a courtesy to assist you to the extent of our abilities. For more information on our statement of support, feel free to click here.
For legacy Grid users, another helpful resource is the GPU tool. This will allow you to take a look at all the sites on your server and narrow down which ones are using the most resources.
In this example we will be using GTMetrix, as it allows us to see POST data.
- Go to https://gtmetrix.com and search your domain's URL.
Be sure to change example.com to your actual domain name.
- After a few minutes, GTMetrix will provide your test results. Click on Waterfall.
- Scroll through the Waterfall until you find admin-ajax.php.
You may notice looking at the purple graph that the admin-ajax is significantly slower than the rest of our site.
- Click on the admin-ajax data entry. Then click on the POST tab.
- The results in the POST tab will look different for each website. But in this example, what we found is "action=tve_dash_front_ajax." This line of code is telling us the application that admin-ajax.php is calling for.
- By looking up "tve" and "WordPress" in Google, we were able to find out this is coming from a third-party plugin, and thus we have found the culprit of our high usage.
Third-party plugins are the most common reason for for high usage by admin-ajax. Once you have found a culprit plugin, to lower your usage you can try:
- Updating the plugin.
- Disable the plugin (if you don't need it).
- Contacting your developer, or the plugin's support team to see if they can advise different settings to change in your plugin.
- Moving or upgrading to a different server that will have more resources for your plugin.
A less common, but possible contributor to high admin-ajax usage is the WordPress Heartbeat API. As mentioned earlier, the admin-ajax contributes to things such as autosaving, which by default occurs every 15 seconds. This can potentially add up and start taking up your servers resources. Usage coming from the Heartbeat API may not show up in front-end speed tests like we found in earlier using GTMetrix.
- A way to remedy this is by installing the Heartbeat Control plugin.
- After installing Heartbeat Control, go to Settings >> Heartbeat Control Settings.
- You can allow or deny Heartbeat under certain circumstances, or you can modify the frequency from the default of 15 seconds, to something higher such as 60 seconds. This will help lower the usage that can occur through the Heartbeat API.
The exact settings you will want to use can vary depending on your site. So for best practices you can consult your web developer on which options are best for you.