NextGen/Imagely suddenly causing huge spikes in load ave on server
-
NextGen/Imagely (v 4.1.1) is suddenly causing huge spikes in load ave on server. It’s paralyzing our site. As soon as we disable it, the load ave goes back to normal. Activate it again, and it spikes way, way up. Our WordPress is the latest version.
Technical Evidence:
- Slow Log Trace: Our
php-fpm/www-slow.logconsistently flags NextGEN during thewp_enqueue_scriptsandtemplate_redirecthooks.- Offending Functions:
NextGEN_Gallery\DataMappers\DisplayType::run_query()andNextGEN_Gallery\DataMapper\WPPostDriver::query(). - The Bottleneck: It appears the
mysqli_querycalls inside the DataMapper are taking excessive time, even on pages where no gallery is present.
- Offending Functions:
- FPM Status Trace:
NextGEN_Gallery\Display\DisplayManager::enqueue_frontend_resources()is frequently at the top of the stack during load spikes.- This suggests the Resource Manager is performing heavy database lookups on every single page load to determine which assets to inject.
- Environment Details:
- PHP version: [8.4]
- Object Cache: Redis is active (
object-cache.phpis present), but NextGEN’s internal queries do not seem to be hitting the cache efficiently. - Theme: GeneratePress.
Our database tables are small (e.g.,
ngg_picturesis only 25MB), yet the slow log showsrun_query()andfind_by_name()taking several seconds to complete. This suggests a PHP-level bottleneck or an inefficient loop in theDataMappers\DisplayTypeclass rather than a slow MySQL query.We have several large galleries with 2,000–3,000 images each. The
slow.logshows the bottleneck is inDataMappers\DisplayTypeandWPPostDriver. It appears the plugin is attempting to load/map the entire gallery metadata into memory on every page load, rather than using pagination or lazy-loading at the database level.Questions:
- Is there a way to prevent the Resource Manager from scanning the database on every request for pages that do not contain a
[ngg]shortcode or block? - Why are
find_by_name()andrun_query()in theDisplayTypemapper taking 5+ seconds to execute on a high-spec dedicated server? - Are there specific global settings we should disable to stop NextGEN from hooking into
wp_enqueue_scriptsso aggressively?
- Slow Log Trace: Our
You must be logged in to reply to this topic.