How to Resolve the High Resource Consumption of WordPress Admin-ajax.php Process
WordPress Heartbeat is an API introduced in version 3.6 back in the days. This API simulates the bidirectional connection between the client browser and the server where the WordPress site is hosted. The API features many implementations but the most important are:
- Live communication between the client’s browser and the web-server with Ajax (no web page refresh needed)
- Improved user session management
- Tracking of different post revisions
- Auto-Saving posts
With such features, it is undoubtedly quite a handy tool that is fully enabled by default in WordPress.
Recently we discovered that due to the Heartbeat functionality, our Shared Hosting clients are experienced a major issue with the resource consumption of their websites. It appears that in order for the WordPress Heartbeat to work properly, it spawns an additional admin-ajax.php process, which is making the Ajax requests to the index.php file of the wp-admin section.
Here is a simple example:
00:45:11 "POST /wp-admin/admin-ajax.php "http://example.com/wp-admin/index.php"
00:45:67 "POST /wp-admin/admin-ajax.php "http://example.com/wp-admin/index.php"
This is resulting in the constant spawn of new admin-ajax.php processes which are consuming quite a lot of resources:
503 user 20 0 358m 33.8 0.2 0:00.35 /home/user/public_html/wp-admin/admin-ajax.php
508 user 20 0 387m 25.1 0.4 0:00.79 /home/user/public_html/wp-admin/admin-ajax.php
The amount of spawned processes sometimes exceeds the number of allowed processes on our Shared Hosting environment, and this is resulting in 508 – “Resource limit reached”. This error can also be received if there is no CPU/RAM available for your account. That can happen because it has reached the virtually assigned limits or the hardware limitation in case you are using a service like our Dedicated Servers.
The only common solution applicable by every WordPress user is actually quite a simple one – You need to either disable the Heartbeat API or you need a way to control it.
To control the API, you need to be fully aware of what it does, and also you should be well familiar with the code and the functionality of the WordPress application. In case you do not have the time to spare in order to check all the whitepapers, you should read the next few lines of this post.
The simplest and most effective solution to this issue is to install a plugin called Heartbeat Control. If you are not quite sure how to do that, please check our “Managing the plugins of your website” tutorial, where you will receive detailed and well-structured information on how to perform plugin installations.
Once you install the plugin, you will need to activate it, and then an additional item named Heartbeat Control will emerge into the Settings menu of your WordPress application.
If you click on that item, you will see quite a simple interface for the management of the Heartbeat API. Here you can use the Disable Heartbeat options to stop the API in your WordPress Dashboard, Frontend, or Post Editor sections. Click on the Save Changes button to preserve the configuration.
Heartbeat is not mandatory for your WordPress website to work properly, and indeed this is the reason why sometimes WordPress owners are experiencing severe resource consumption issues with their web hosting services. FastComet fully supports the suggested fix, and we will gladly apply it for any customer of our services who would like to boost the performance of the used WordPress application.
The latest tips and news from the industry straight to your inbox!
Join 30,000+ subscribers for exclusive access to our monthly newsletter with insider cloud, hosting and WordPress tips!