WordPress Heartbeat: what it is and why it keeps calling the server

The short answer: Heartbeat is a “pulse” that WordPress sends to the server every few seconds while the dashboard or the editor is open. It is used to save drafts, warn that someone else is editing the same page, and check whether your session has expired. With many tabs open, that is many requests to the server. The cure is to slow it down, not to switch it off.

Each pulse is a request to the admin-ajax.php file with the action heartbeat. The interval depends on the screen: shorter in the page editor, longer in the rest of the dashboard. By default it runs in the dashboard and in the editor, and not on the pages visitors see.

How to tell whether it is Heartbeat

1 In cPanel, open Raw Access and look for many lines with POST /wp-admin/admin-ajax.php. How to read that page is in Reading the Errors and Raw Access pages.
2 If the site slows down or hits its limit while someone is editing, and calms down when that person closes the tabs, Heartbeat is a good suspect.
3 To confirm it properly, follow admin-ajax eating your resources: the same file serves many things, and Heartbeat is only one of them.

What to do

Measure What changes
Close dashboard tabs nobody is using Every open tab, even one forgotten overnight, keeps sending pulses. It is the simplest measure and the one that fixes most.
Lengthen the interval between pulses WordPress accepts an interval set in code. You keep all the protection with fewer requests.
Switch it off completely It ends the requests, but you lose safe autosave, the warning about simultaneous editing and the expired-session notice. Only do this knowing what you lose.

To lengthen the interval, add this code to the functions.php of a child theme, or to a code-snippets plugin (see A plugin or a snippet of code):
add_filter( 'heartbeat_settings', function ( $settings ) {
$settings['interval'] = 60;
return $settings;
} );

The number is in seconds. Measure before and after, as in What eats CPU on a website.

Always edit with a safe copy. A mistake in functions.php leaves the site on a white page. Take a backup first and know how to get in without the dashboard: see Disabling plugins, including when you cannot get in.
If the problem only appears when several people edit at once, the real limit may be the account’s and not Heartbeat’s: see Entry processes: why a site with few visitors can still hit the limit.

The site slows down when someone edits and you cannot tell why? Open a ticket with the address and the time it happened.

Open a support ticket

SEE ALSO

admin-ajax eating your resources: how to find out and cut it down

What eats CPU on a website, and how to bring it down

Entry processes: why a site with few visitors can still hit the limit

Swapping WP-Cron for a real server cron job

RECOMMENDED PRODUCT

WordPress hosting

One-click install, updates handled, and speed that holds up. from $6.60/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?