Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

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

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Wordpress

WordPress: Fix admin-ajax.php Timing Out Under Plugin Load

- 02.12.26 - ErcanOPAK

📝 WordPress: Fix admin-ajax.php Timing Out Under Plugin Load

Every wp.ajax.post() call from the block editor, a form plugin, or a heartbeat check routes through the single shared admin-ajax.php endpoint, which bootstraps the entire WordPress environment — every active plugin, the full theme, and the whole plugin hook system — before it even looks at which specific ajax action was requested. On a site where several plugins each hook into init or plugins_loaded with their own expensive setup (registering dozens of custom post types, warming a cache, calling out to a license-check API), that full bootstrap cost is paid on every single ajax request, not just full page loads, and under concurrent load from something like the editor’s autosave heartbeat firing from several open tabs, those bootstraps queue up behind each other and the request simply times out before WordPress ever reaches the actual ajax handler.

🔎 The Problem

Server access log during active editing with 3 browser tabs open:

POST /wp-admin/admin-ajax.php (action=heartbeat)      -> 504, 28.0s
POST /wp-admin/admin-ajax.php (action=heartbeat)      -> 504, 27.8s
POST /wp-admin/admin-ajax.php (action=autosave)       -> 504, 29.1s

New Relic / query monitor trace for ONE of those requests:
  plugins_loaded hook: 22.4s total
    - license-check-plugin: 9.8s (blocking HTTP call to vendor API)
    - cpt-registration-plugin: 6.1s (file scan on every request)
    - cache-warm-plugin: 4.9s
  actual ajax action callback: 0.06s   <- the real work is instant

âś… Fix: Keep plugins_loaded Light and Make admin-ajax Aware of It

  • Move any plugin’s blocking network calls (license checks, remote config fetches) out of plugins_loaded/init and behind a transient cache with a short TTL, so the expensive call happens once every few minutes in the background instead of synchronously on every single ajax request.
  • Wrap expensive one-time setup (like a custom post type file scan) in a check for wp_doing_ajax() combined with the specific $_REQUEST['action'] values that actually need it, so unrelated ajax actions like heartbeat don’t pay for work they never use.
  • Reduce the Heartbeat API’s polling interval via heartbeat_settings filter on the specific admin screens where it’s firing most aggressively, since fewer concurrent heartbeat requests means fewer bootstraps competing for the same slow plugins_loaded work at once.

🚨 Why This Is Dangerous

  • A timing out admin-ajax.php doesn’t just break autosave — it silently breaks every other plugin that shares the same endpoint, including ones with no relation to the slow plugin at all, because the bottleneck is in the shared bootstrap every ajax request has to pass through first.

admin-ajax.php doesn’t care which action you asked for until after it has already paid the full cost of being WordPress — and a fast handler behind a slow bootstrap is still a slow request.

— WordPress Admin

Related posts:

WordPress: Disable Pingbacks to Stop Comment Spam

WordPress: Disable Pingbacks to Stop Comment Spam

WP “Menus Not Saving” — The Max Input Vars Killer

WP “Menus Not Saving” — The Max Input Vars Killer

WordPress: Stop 'Briefly Unavailable for Scheduled Maintenance' From Getting Stuck Forever

WordPress: Stop 'Briefly Unavailable for Scheduled Maintenance' From Getting Stuck Forever

Views: 0
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

Asp.Net Core: Fix the Data Protection Key Ring Rotating Too Often
The AI Prompt That Debugs IndexedDB Version Clashes

Leave a Reply Cancel reply

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

Most Read

  1. 01How to make theater mode the default for Youtube 1,080 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 869 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 672 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 585 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

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

Social

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