Mahamudul Hasan Rubel
HomeAboutProjectsSkillsExperienceBlogPhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • About
  • Projects
  • Skills
  • Experience
  • Blog
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
WordPressJune 24, 20264 min read

WordPress Heartbeat API: Managing Admin Background Processes

The WordPress Heartbeat API powers real-time admin features, but it can slow down your site. Learn how to optimize or disable it for better performance.

WordPressHeartbeat APIPerformanceAdminPHPOptimizationTutorial

If you’ve ever opened your browser’s Network tab while sitting in the WordPress dashboard, you’ve likely seen a constant stream of POST requests hitting admin-ajax.php. That’s the WordPress Heartbeat API in action, working away in the background. It’s the engine behind auto-saves, post-locking, and login session management.

I remember the first time I really looked at those requests. I was troubleshooting a client site that felt sluggish whenever multiple editors were working simultaneously. We were seeing a request every 15 to 60 seconds, which, at scale, creates significant overhead. Understanding how this browser-to-server communication works is the first step toward reclaiming your server’s resources.

What is the WordPress Heartbeat API?

At its core, the WordPress Heartbeat API is a heartbeat mechanism that uses admin-ajax.php to send periodic pulses from the browser back to your server. When a page is open in the admin area, JavaScript triggers these pulses. The server then executes a set of registered callbacks and sends a response back.

It’s essentially a lightweight polling system. While it keeps the UI feeling "live"—like notifying you if someone else is editing a post—it consumes PHP processes and database connections. If you're struggling with high CPU usage or database locks, it's often worth checking if your WordPress background processes are firing more often than they need to.

The Trade-offs of Constant Communication

When I first started optimizing dashboard performance, I assumed the best move was to kill the heartbeat entirely. I quickly learned that was a mistake. I broke the autosave functionality, and a client lost about 20 minutes of work during a session timeout.

The lesson? Don't just disable things blindly. If you need to optimize your WordPress admin optimization strategy, you have to find the middle ground.

How to Throttle the Heartbeat

If you find that the default pulse is too aggressive, you don't have to turn it off. You can simply slow it down. WordPress allows you to hook into the heartbeat settings via JavaScript.

JAVASCRIPT
jQuery(document).on(CE9178">'heartbeat-config', function(event, config) {
    config.interval = 120; // Pulse every 120 seconds instead of the default
});

By pushing the interval to two minutes, you drastically reduce the number of concurrent connections hitting your server. It’s a subtle change that can drop your server load by roughly 30% in high-traffic admin environments.

When to Disable the Heartbeat

Sometimes, you just don't need it. If you’re the sole admin on a site, or if you’ve built a custom interface that doesn't rely on post-locking, you can disable it entirely.

I prefer to use a filter in functions.php rather than a plugin for this. It keeps the environment clean and avoids adding extra overhead to the boot process.

PHP
add_action( 'init', 'my_stop_heartbeat', 1 );
function my_stop_heartbeat() {
    wp_deregister_script('heartbeat');
}

This effectively kills the script from loading, stopping all communication. Just be careful: if you’re working on a multi-author site, disabling this will prevent WordPress from warning users if two people are editing the same post.

Moving Beyond Simple Ajax

While managing the heartbeat is vital for admin stability, it's only one piece of the puzzle. If you're building out complex features, you might want to look into how the WordPress REST API Performance: Brotli Compression for Headless SaaS can handle data delivery more efficiently than traditional Ajax calls.

Also, if your heartbeat issues are actually symptoms of underlying database strain, WordPress Performance: Database Query Memoization for REST APIs might be a more effective path to fixing your bottleneck.

FAQ

Does the Heartbeat API run on the front end?

By default, the Heartbeat API is restricted to the WordPress admin dashboard. It doesn't run on the front end unless a theme or plugin explicitly enqueues it.

Will disabling it break my site?

If you're the only user editing posts, probably not. However, you will lose autosave functionality and session expiration warnings. Always test in a staging environment first.

Is it better than WebSockets?

For WordPress, yes—at least for now. While WebSockets are technically more efficient for real-time data, they are notoriously difficult to implement reliably in standard shared hosting environments. The Heartbeat API is the "good enough" solution that works everywhere.

I’m still experimenting with ways to move non-essential admin background tasks into the background using Action Scheduler or similar queue runners. The goal is to keep the admin interface snappy without sacrificing the utility of the built-in system. Keep an eye on your admin-ajax.php logs; they usually tell you exactly what’s causing the most noise.

Back to Blog

Similar Posts

WordPressJune 23, 20264 min read

WordPress Rewrite API: Managing Rules and Flush Failures

Master the WordPress Rewrite API and learn why calling flush_rewrite_rules incorrectly ruins performance. Get expert tips on managing WordPress permalinks.

Read more
WordPressJune 22, 20264 min read

WordPress Performance: Streaming Large REST API Exports

Optimize WordPress performance for large REST API exports by using PHP generators and database streaming to slash memory overhead. Stop hitting memory limits.

Read more
WordPressJune 21, 20264 min read

WordPress Options API: Understanding Autoloading and Performance

Master the WordPress Options API by understanding how the wp_options table handles autoloading. Learn to optimize your database and speed up your site today.

Read more