When troubleshooting a slow WordPress website, most developers start by checking plugins, themes, caching, and database queries.

But have you ever considered that WordPress itself might be generating repeated background requests?

That's exactly what I discovered while investigating a client's website. (Related: Tech Report: โ€œDeterminedโ€ woman completes 7 marathons i...)

In my previous article, I shared how a client's WordPress website had numerous plugins installed and was experiencing performance problems.

During my investigation, I contacted the hosting provider's support team and asked them to examine the server logs. (Related: Intel Diamond Rapids reveals signs of life in SC26 demo...)

They reported a massive number of requests associated with something called the WordPress Heartbeat API.

At the time, I wasn't familiar with Heartbeat or how it worked.

What I discovered was an crucial WordPress feature that many developers use indirectly without realizing it.

In this article, I'll explain what the WordPress Heartbeat API is, how it works, when it can affect performance, and how to investigate and control it safely.

The WordPress Heartbeat API is a built-in feature introduced in WordPress 3.6.

It allows communication between the user's browser and the WordPress server at regular intervals without requiring a full page reload.

This communication uses AJAX requests.

Heartbeat supports several vital WordPress features, including:.

For example, imagine two authors working on the same WordPress website.

When one author starts editing a post, WordPress can notify the second author that the post is already being edited.

Heartbeat helps make that communication possible.

It's a useful feature, but it also creates server requests.

Heartbeat uses JavaScript on the browser side and PHP on the server side.

The process is relatively straightforward:.

These requests commonly use the following endpoint:.

The request typically includes an action parameter:.

The notable detail is that admin-ajax.php is not exclusive to Heartbeat.

Many WordPress plugins and themes also use this endpoint for their own AJAX operations.

Therefore, seeing requests to admin-ajax.php doesn't automatically mean Heartbeat is responsible.

You need to inspect the request payload to identify the action.

Heartbeat uses a configurable interval that varies depending on the WordPress context and activity.

A commonly used default interval is around 15 seconds, although actual behavior can differ between screens and configurations.

Heartbeat can also slow its polling when browser activity changes.

This means it isn't necessarily sending requests at a fixed rate under every condition.

A single Heartbeat request usually isn't a problem.

The concern arises when many requests are generated or when processing them becomes expensive.

Suppose Heartbeat sends one request every 15 seconds.

Now imagine 10 consumers have WordPress administration pages open simultaneously.

Under those simplified assumptions, the site could receive:.

Sources indicate that these are illustrative calculations, not measurements from my client's website. Actual request counts depend on browser activity, WordPress configuration, and other factors.

Each request may require PHP processing and could trigger additional plugin callbacks.

On a server with limited resources, excessive or expensive requests can contribute to performance problems.

An administrator might have several WordPress dashboard tabs open.

If Heartbeat is active in multiple tabs, each may generate periodic requests.

Some plugins extend Heartbeat with their own functionality.

Poorly optimized callbacks can increase the amount of processing performed during a Heartbeat request.

On hosting environments with constrained CPU or PHP worker capacity, background requests can compete with other requests for resources.

However, Heartbeat requests alone don't prove the cause of a performance matter.

They are a signal worth investigating.

You don't necessarily need a performance plugin to inspect Heartbeat activity.

Your browser's developer tools are a useful starting point.

Leave the page open long enough to observe whether requests repeat.

Click a request and inspect its payload.

If you see that action, you've identified a Heartbeat request.

You can also inspect the request's timing and response.

Remember that the total request duration isn't the same as PHP execution time, and a slow request doesn't necessarily mean Heartbeat itself is inefficient.

Browser DevTools show requests from your own browser session.

Server logs can help reveal request patterns across the website.

You can ask your hosting provider to investigate:.

This is exactly why contacting hosting support was valuable in my client's case.

The logs gave me a technical lead that wasn't obvious from looking at the website.

Once you've confirmed that Heartbeat activity deserves investigation, you can consider adjusting its behavior.

However, I wouldn't recommend disabling it globally as a first step.

Heartbeat supports useful functionality, and changing it can affect the editing experience.

WordPress provides the heartbeat_settings filter, which lets developers modify Heartbeat settings.

This example sets the polling interval to 60 seconds.

You can place the code in a small custom plugin or another appropriate location where your WordPress customizations are managed.

The interval is subject to WordPress's supported limits, and the effective polling behavior may vary depending on the page and activity.

Vital: Increasing the interval reduces polling frequency, but it also means Heartbeat-dependent updates may take longer.

Always test the affected functionality.

Rather than changing the interval everywhere, you can apply a different setting on a particular administration screen.

This example targets the main WordPress dashboard screen.

It doesn't globally disable Heartbeat or change the post editor's interval.

Screen-specific changes can be preferable when you've identified a particular area that needs adjustment.

WordPress also provides a way to dequeue scripts.

This example attempts to remove Heartbeat from the main dashboard page.

It should only be used after confirming that no required functionality on that screen depends on Heartbeat.

I would avoid disabling Heartbeat throughout the administration area, especially in the post editor, without understanding the consequences.

My preference is to investigate and make targeted adjustments rather than disabling core functionality blindly.

After changing Heartbeat settings, return to the browser's Network tab.

Check whether the frequency of Heartbeat requests has changed as expected.

Then test important WordPress functionality.

Ideally, compare measurements before and after the change under similar conditions.

If you have access to server monitoring, look at PHP worker utilization, CPU activity, and request volume.

A reduction in Heartbeat requests doesn't automatically prove that the website became faster.

The objective is to determine whether the change improved the original problem without introducing new problems.

When the hosting provider first mentioned WordPress Heartbeat, I didn't know much about it.

I had worked with WordPress for years, but this particular feature wasn't something I had previously needed to investigate in detail.

The experience reminded me of three vital lessons.

Looking at the website's frontend doesn't always reveal what is happening on the server.

Logs and resource metrics can provide valuable evidence.

Plugins can be useful, but adding one without understanding the problem can make the setup more complicated.

Sometimes WordPress already provides the hooks and tools needed to investigate or adjust a feature.

What matters is the ability to investigate unfamiliar behavior, understand the underlying system, and evaluate possible solutions.

In my case, a real client problem motivated me to learn about a WordPress feature I hadn't previously explored.

And that knowledge became useful beyond the original project.

One final point worth mentioning is that Heartbeat and WP-Cron are different mechanisms.

Both are worth understanding when troubleshooting WordPress performance, but they should not be confused.

In my next article, I'll explore WP-Cron in more detail, including how it works, why scheduled tasks sometimes fail or run late, and when using a real server cron job can be useful.

The WordPress Heartbeat API is not a bug or an unnecessary feature.

It provides useful functionality that helps WordPress deliver a better editing and administration experience.

However, like any server-side activity, it can contribute to performance problems under certain conditions.

The key is understanding how it works, measuring its impact, and making changes only when the evidence supports them.

My experience with a client's website taught me that troubleshooting isn't always about finding a latest tool.

Sometimes it's about discovering a feature you didn't know existed.

Before disabling Heartbeat or installing another optimization plugin, investigate the requests and understand what's actually happening.

I'm a WordPress developer specializing in custom WordPress development, WooCommerce, PHP, and JavaScript.

You can explore my work on GitHub.

If you've encountered excessive Heartbeat requests on a WordPress website, I'd be interested to hear how you investigated them.

Have you ever discovered an unexpected WordPress feature while troubleshooting a client project?

โ†’ Read original article