Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Wordpress

WordPress: Speed Up Admin Dashboard by Disabling Heartbeat API

- 03.02.26 - ErcanOPAK

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

Related posts:

Custom REST Endpoint Without a Plugin

WordPress Media Library Becomes Unusable Over Time

WordPress Pages Randomly Lose Styles

Post Views: 4

Post navigation

Photoshop: Fix Blurry Text After Transform with This One Setting
WordPress: Limit Login Attempts Without Plugins Using .htaccess

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

March 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Feb    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (938)
  • How to add default value for Entity Framework migrations for DateTime and Bool (836)
  • Get the First and Last Word from a String or Sentence in SQL (828)
  • How to select distinct rows in a datatable in C# (801)
  • How to make theater mode the default for Youtube (736)
  • Add Constraint to SQL Table to ensure email contains @ (575)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (554)
  • Average of all values in a column that are not zero in SQL (523)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (477)
  • Find numbers with more than two decimal places in SQL (441)

Recent Posts

  • C#: Saving Memory with yield return (Lazy Streams)
  • C#: Why Records are Better Than Classes for Data DTOs
  • C#: Creating Strings Without Memory Pressure with String.Create
  • SQL: Protecting Sensitive Data with Dynamic Data Masking
  • SQL: Writing Readable Queries with Common Table Expressions (CTE)
  • .NET Core: Handling Errors Gracefully with Middleware
  • .NET Core: Mastering Service Lifetimes (A Visual Guide)
  • Git: Surgical Stashing – Don’t Save Everything!
  • Git: Writing Commits That Your Future Self Won’t Hate
  • Ajax: Improving Perceived Speed with Skeleton Screens

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (938)
  • How to add default value for Entity Framework migrations for DateTime and Bool (836)
  • Get the First and Last Word from a String or Sentence in SQL (828)
  • How to select distinct rows in a datatable in C# (801)
  • How to make theater mode the default for Youtube (736)

Recent Posts

  • C#: Saving Memory with yield return (Lazy Streams)
  • C#: Why Records are Better Than Classes for Data DTOs
  • C#: Creating Strings Without Memory Pressure with String.Create
  • SQL: Protecting Sensitive Data with Dynamic Data Masking
  • SQL: Writing Readable Queries with Common Table Expressions (CTE)

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com