i did some profiling using nginx and found a bottleneck in the theme.

I fixed that bottleneck, and on the test server, the page loads ok fast


on our production site, the patch improved page loading, but we are still extremely slow.

I am not sure what is causing that. We use AWS with load balancing. Sadly, the server run apache and not nginx.


what are my options to figure out what is causing the bottle neck?

what I did is measure the load time of functions.php with my patch, it is at around 30 ms. Without patch functions.php loads in like 4 seconds. Now it is still very slow, and I am not sure what my next options / steps are to fix the problem.

maybe the load balancing is causing some timeout in some plugin function?

UPDATE so i did this to wp-includes/plugin.php (first backup that file)

function do_action()...

    reset( $wp_filter[ $tag ] );

    do {
        foreach ( (array) current($wp_filter[$tag]) as $the_ )

            if ( !is_null($the_['function']) ){
        $func = $the_['function'];
          $t = key($func);
          $func = $func[$t];


          if(! is_callable([$t, '__toString']) && !is_scalar($t)){
            $func = get_class($t);
        if(!is_callable([$func, '__toString']) && !is_scalar($func)){
          $func = get_class($func);
       ilog2((string)$func. ' start ');
                call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
       ilog2((string)$func. ' end ');

    } while ( next($wp_filter[$tag]) !== false );


function ilog2($m){
  global $isac_start;
  $time_elapsed_secs = 1000 * (microtime(true) - $isac_start);
  file_put_contents(__DIR__. '/../wp-content/' . 'debug_filter_log.txt', $m . "||| ms: " . $time_elapsed_secs . "\n", FILE_APPEND | LOCK_EX);

$isac_start is defined in my functions.php as

global $isac_start;
$isac_start = microtime(true);

the output I got, the interesting parts were this:

wp_print_styles start ||| ms: 247.50804901123
Jetpack start ||| ms: 247.5528717041
Jetpack end ||| ms: 256.79087638855
print_emoji_styles start ||| ms: 256.88886642456
print_emoji_styles end ||| ms: 256.91390037537
WordPressHTTPS_Module_Core start ||| ms: 256.93488121033
WordPressHTTPS_Module_Core end ||| ms: 258.43501091003
wp_print_styles end ||| ms: 1000.9169578552

wp_print_head_scripts start ||| ms: 1001.072883606
wp_just_in_time_script_localization start ||| ms: 1001.1320114136
wp_just_in_time_script_localization end ||| ms: 1001.1949539185
WordPressHTTPS_Module_Core start ||| ms: 1001.2218952179
WordPressHTTPS_Module_Core end ||| ms: 1003.1979084015
ReduxFramework start ||| ms: 1003.2269954681
ReduxFramework end ||| ms: 1003.6089420319
wp_print_head_scripts end ||| ms: 1384.2549324036

wp_print_footer_scripts start ||| ms: 2234.1909408569
Jetpack start ||| ms: 2234.2219352722
Jetpack end ||| ms: 2235.0518703461
_wp_footer_scripts start ||| ms: 2235.1009845734
_wp_footer_scripts end ||| ms: 3960.3469371796
wp_print_footer_scripts end ||| ms: 3960.4659080505

but I am not sure how to continue from here


It is impossible to just guess what the performance issue is, it might not be related to a web server at all.

Your options with WordPress are (scope ascending):

  1. PHP runtime profiler / debug code for basic timing of WP load.
  2. PHP engine profiler (binary extension), such as Blackfire.
  3. Full stack profiler (server software, etc), such as New Relic.

You should start with PHP runtime to figure out if your time sinks within WordPress page load. It might or it might not. From there it depends if you need to be further troubleshooting PHP or the problem actually is with web server running it.

| improve this answer | |
  • see updated question – Toskan Nov 30 '16 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.