Dashboard load times with gethostbyaddr()
-
Hey there,
I use Dashboard Widgets Suite on a number of WordPress sites and have used it for years (thanks!!), primarily for the System Info, Control Panel, Error Log, and Debug Log widgets.
I’ve been tracking down a very slow WordPress dashboard issue (14–20 second load times) and eventually narrowed it down to the System Info widget.
Using our PHP-FPM slow log, every slow request pointed to the same call stack:
gethostbyaddr()
dashboard_widgets_suite_get_host_name()
dashboard_widgets_suite_get_client_infos()
dashboard_widgets_suite_system_info()
wp_dashboard()Specifically, this function:
function dashboard_widgets_suite_get_host_name() {
return isset($_SERVER['REMOTE_ADDR'])
? sanitize_text_field(gethostbyaddr($_SERVER['REMOTE_ADDR']))
: 'n/a';
}The reverse DNS lookup performed by
gethostbyaddr()appears to block page generation while waiting for the lookup to complete.Couple things I noticed:
- The issue occurs on multiple servers.
- It also occurs on sites that are both behind and not behind Cloudflare.
- CPU, MySQL, Redis, and disk I/O were all normal.
- As soon as I bypassed only the
gethostbyaddr()call, the WordPress dashboard became nearly instantaneous (around 1–2 seconds instead of 14–20 seconds).
Not sure why this is happening but I thought I’d report it.
Thanks!
You must be logged in to reply to this topic.