WordPress admin panel sluggish and using 100% CPU? The Heartbeat API polls your server every 15 seconds for autosave and notifications, eating resources.
What Heartbeat Does:
Every 15 seconds: - Check for new comments - Check for plugin updates - Autosave post drafts - Notify about other users editing same post - Trigger scheduled tasks Result: 240 requests per hour per admin user On busy sites: Server struggles, admin panel freezes
The Fix – Disable Heartbeat:
Add to functions.php (or use plugin “Heartbeat Control”):
// Completely disable Heartbeat
add_action('init', function() {
wp_deregister_script('heartbeat');
}, 1);
Better: Control It Instead of Disabling:
// Slow down Heartbeat to 60 seconds (instead of 15)
add_filter('heartbeat_settings', function($settings) {
$settings['interval'] = 60; // seconds
return $settings;
});
// Disable Heartbeat on frontend (keep for admin)
add_action('init', function() {
if (!is_admin()) {
wp_deregister_script('heartbeat');
}
}, 1);
// Disable everywhere except post editor
add_action('init', function() {
global $pagenow;
if ($pagenow != 'post.php' && $pagenow != 'post-new.php') {
wp_deregister_script('heartbeat');
}
}, 1);
Performance Impact:
Before (15 sec interval): - 240 requests/hour/user - 10 active admins = 2400 requests/hour - Each request: 50-200ms server time - Total server load: 2-8 minutes CPU per hour After (60 sec interval): - 60 requests/hour/user - 10 active admins = 600 requests/hour - 75% reduction in background load - Admin dashboard feels snappier
Side Effects of Disabling:
❌ No autosave while writing posts
❌ Won’t see “User X is editing this post” warnings
❌ Comment moderation notifications delayed
✅ But: Admin dashboard 3-5x faster
✅ Server load reduced by 60-80%
Recommended Setup:
// Disable on frontend (visitors don't need it)
add_action('init', function() {
if (!is_admin()) {
wp_deregister_script('heartbeat');
}
});
// Slow down in admin dashboard
add_filter('heartbeat_settings', function($settings) {
$settings['interval'] = 60;
return $settings;
});
// Keep normal speed in post editor (for autosave)
add_filter('heartbeat_settings', function($settings) {
global $pagenow;
if ($pagenow == 'post.php' || $pagenow == 'post-new.php') {
$settings['interval'] = 15; // Keep fast for editing
}
return $settings;
});
Alternative: Use Plugin
Install “Heartbeat Control” plugin:
– GUI to control Heartbeat per page
– No code needed
– Can set different intervals for dashboard/frontend/editor
Check If Heartbeat Is The Problem:
Open browser DevTools → Network tab → Filter: “heartbeat”
If you see requests every 15 seconds consuming 200-500ms, it’s the culprit!
// Typical Heartbeat request: POST /wp-admin/admin-ajax.php Action: heartbeat Response time: 250ms Every 15 seconds = Noticeable slowdown on slower servers
