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 WordPress is hosted at. 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 surely quite a handy tool which is fully enabled by default in WordPress.

The Problem

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 exceed the amount 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 are no CPU/RAM available for your account due to the fact that it has reached the virtually assigned limits or the hardware limitation in case you are using a service like our Dedicated Servers.

The Solution

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.

In order 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.

Install Hardbeat Control Plugin for WordPress with FastComet

Once the plugin is installed you will need to activate it and then an additional link called “Heartbeat Control” will emerge into the “Settings” menu of your WordPress application.

Find the Additional Heartbeat Control Link in Settings

If you click on that link you will see quite a simple interface for the management of the Heartbeat API. In order to completely disable the API please use the “Disable Everywhere” option from the “Control heartbeat locations” and then the “Save Changes” button so the configuration can be activated.

How to Completely Disable Heartbeat Control in WordPress

Of course, the plugin offers few other adjustments to the API depending on your needs and you should review those of course if you need to disable it for some concrete locations on your website.

The Conclusion

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.

Christopher

Christopher has many years of experience leading teams in the fields of Technical support, Server Administration, and Product Development. He mainly works on the backend, helping to create the infrastructure that powers FastComet. He is responsible for flawless migrations and quick and efficient answers to client questions. He also monitors our network status and jumps in to solve time-sensitive issues like DDoS attacks and stops malicious attempts in their tracks. Christopher’s primarily responsible for making sure that our servers purr along, and has worked tirelessly to improve automation at FastComet.