Digital Marketing

Resolve the WordPress connection lost issue with heartbeat control plugin

Google+ Pinterest LinkedIn Tumblr

WordPress connection lost issue with heartbeat control plugin

Resolve the WordPress connection lost issue with heartbeat control plugin

For new bloggers, server resource management is a major issue. Most new blogs are based on cost-effective shared hosts, which is understandable. You want to keep the running costs low.

But there is the obvious downside. Shared hosts have their limitations as they need to distribute the resource among all the hosted sites. Hundreds of sites are hosted on the same IP address, and hosts take every step to ensure that no one site abuses the resources.

So while it’s cost-effective, you must be aware of the potential pitfalls (read: resource heavy stuff) that you need to avoid.

One major resource waster for WordPress blogs is the Heartbeat API. More on what it does later.

You should be more concerned about the problems it can create.

On shared hosts, this can often give you a “connection error” message on WordPress.

Even worse, this connection error due to Heartbeat API over usage can prevent you from editing your posts. It will give a message on these lines

Connection lost. Saving has been disabled until you’re reconnected. We’re backing up this post in your browser, just in case.

connection lost error due to heartbeat api

Connection lost error due to heartbeat API

 How to identify a Heartbeat API based issue?

You can roughly identify a case of Heartbeat API based issue by monitoring your admin-ajax.php usage.

Just run a site speed test on Pingdom and check the amount of time spent on admin-ajax.php. If there is the indication of heavy admin-ajax.php usage, heartbeat API may be the culprit. In fact, your web host may even notify you about excess resource usage through admin-ajax.php

What is Heartbeat API and what does it do?

Heartbeat API is a new feature that was released with WordPress 3.6. Here is what the developer had to say about it.

The purpose of this API is to simulate bidirectional connection between the browser and the server. Initially it will be used for autosave, post locking and log-in expiration warning while a user is writing or editing.

The idea is to have a relatively simple API that sends XHR requests to the server every 15 seconds and triggers events (or callbacks) on receiving data. Other components would be able to “hitch a ride” or get notified about another user’s activities.

In the future this can be used to block simultaneous editing of widgets and menus or any other tasks that require regular updates from the server.

Basically, the admin-ajax.php is used to make AJAX based connections to the server, directly from your web browser. In layman’s terms, this keeps the server side and admin user side in sync. Any changes on the admin side are automatically notified to the server on a periodic basis. Posts get auto-saved, login expires after a certain amount of time and so on.

What is the problem with Heartbeat API on shared hosts?

The major issue here is that Heartbeat API is very resource intensive. This does not go well with the fact that resource is the limiting factor on shared hosts.

In fact, every open backend page contributes to communication between the server and the browser. Continuous pulse updates are shared between the server and the user, even if the backend is minimized in your browser. This causes unnecessary load on the server. If multiple users are logged in to the backend, this can lead to very high resource usage. Even if a single user keeps multiple pages open, this can lead to a lot of unnecessary resource usage.

What’s the solution? Should you disable it completely?

Not necessarily.

Although it is resource intensive, it contributes to essential functions like autosave feature. The better idea is to use it in a controlled manner so that essential functions are not compromised.

How to control Heartbeat API?

Thankfully, controlling Heartbeat API is very easy. Just download and install this heartbeat control plugin.

Heartbeat API control settings

 

  1. Go to Settings > Heartbeat Control.
  2. Use the drop down to set “Control heartbeat locations” to “Allow only on post edit pages”. This disables Heartbeat API everywhere but posts edit pages. This keeps the autosave functionality intact without the slowdown effect from other pages.
  3. Next, use the drop down to “override heartbeat frequency” to “60 seconds”. This overrides the default value and sets the Heartbeat API usage frequency to 60 seconds. This ensures that requests are sent to the server only after an interval of 1 minute. This prevents unnecessary frequent requests being sent to the server and thus reduces server usage.

 

Your thoughts?

I have given you the easiest way to control the heartbeat API and prevent unnecessary load on your server. I hope this would help you with the “connection lost” problem in the post edit pages. It worked for many.

Let me know if this solves the issue for you. If you face any problems or have further suggestions, please feel free to share in the comments sections.

Resolve the WordPress connection lost issue with heartbeat control plugin

Write A Comment

We have updated new Terms of Service and Privacy Policy, effective May 25, 2018 (Including the GDPR). Learn more
+