Use the WordPress Heartbeat API

A new WordPress performance bottleneck is looming:  admin-ajax.php.

More and more plugins are relying on the admin-ajax.php and the wp_ajax_ hook to deliver their content and functionality making WordPress more dynamic than ever. The problem is that if you have multiple plugins running all making their own wp_ajax calls without concern for what the others do, you end up with 4 or 5 server requests being required to render one page. This is a nightmare for server admins, especially since wp_ajax_ is often implemented as a POST request which allows it to bypass caching from cloudflare or varnish or what have you.

The solution is not to abandon wp_ajax_ but to come up with a better way to manage it. I really like what the Heartbeat API is doing. Instead of each client plugin managing it’s own request, you can tie into an existing “heartbeat” to get the info you need. I would recommend all plugin and theme developers use the Heartbeat API approach if at all possible. At least until wp_ajax_ gets  streamlined.

15 thoughts on “Use the WordPress Heartbeat API

  1. This is an issue that I’m constantly battling and thinking about. The heartbeat api also uses admin-ajax.php, so while it will throttle and batch those requests, it could actually generate more hits (if multiple visitors leave a page open).

    The only true scalable solution I’ve found is using an external service to handle the requests. For example to track and display downloads of an app I use node.js hosted at heroku. Node.js handles these kind of requests with ease and you can request the data from there when needed.

    This is similar to how Jetpack tracks visitors (using and I believe it’s the way to go!

    I think this creates the opportunity for a WordPress specific DBaaS. Imagine a way to store data in an external cache (after page load) then pull it into WordPress automatically (using the companion plugin).

    It’s late for me and I’m on my phone, but I hope this makes sense!

  2. Or possibly use nginx to create a way to write directly to memcache then retrieve it and write it to the database periodically? I may look into this, the issue here would be security.

  3. One other issue is when you are in a scenario where you do not have a co-signer then you may want to try to make use of all of your school funding options. You will find many awards and other free college funding that will present you with finances to help you with institution expenses. Many thanks for the post.

  4. Howdy! I could have sworn I’ve been to this blog before but after reading through some of the post I realized it’s new to me. Nonetheless, I’m definitely happy I found it and I’ll be bookmarking and checking back often!

  5. Hi there! Someone in my Facebook group shared this site with us so I came to take a look. I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers! Superb blog and amazing design and style.

  6. I found your weblog site on google and examine a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN Information Reader. In search of forward to reading more from you afterward!…

  7. Howdy! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely glad I found it and I’ll be book-marking and checking back frequently!

Leave a Reply

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