WordPress slow time to first bite and crashing server issue

I was suffering a slow connection to my website and I was at the end of my tether. The below is a ticket to the WordPress support forums which went un-answered so I thought I’d add my own post about it quickly.

I have latest wordpress with Apache / PHP / MySQL and Varnish in front of it. I have W3 Total Cache working on the server with CDN too.

It seems mostly when logged in the site is crawling, but if I switch to incognito chrome, it loads lightning fast.
I get Varnish 503 errors saying the server is not available but again in incognito the server is loading and pages loading extremely quickly.

I’ve tried disabling all plugins and reinstalling them all. I’ve reconfigured Apache, MySQL and PHP multiple times trying to get optimal settings. However each time it seems to come back to WordPress doing something weird. Everything else looks optimal for my server, even my host says everything on the network and services look spot on.

I’ve tried adding
$this->query(“set session wait_timeout=600” );

As per other forum post suggestions. Has anyone dealt with this problem. It’s persistent and disabling plugins didn’t resolve it. Even the queries look like general WP queries

[Tue Jun 11 11:45:45 2013] [error] [client 127.0.0.1] WordPress database error MySQL server has gone away for query SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (776) ) AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 1 made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/zenko-test/404.php’), get_sidebar, locate_template, load_template, require_once(‘/themes/zenko-test/sidebar.php’), dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, wpzoom_widget_category_sidebar->widget, WP_Query->__construct, WP_Query->query, WP_Query->get_posts, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query

[Tue Jun 11 11:45:45 2013] [error] [client 127.0.0.1] WordPress database error MySQL server has gone away for query SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (6128) ) AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 1 made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/zenko-test/404.php’), get_sidebar, locate_template, load_template, require_once(‘/themes/zenko-test/sidebar.php’), dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, wpzoom_widget_category_sidebar->widget, WP_Query->__construct, WP_Query->query, WP_Query->get_posts, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query

 

The solution it seems was right under my nose. W3 Total Cache database caching. I’ve always had it enabled on the site but for whatever reason it has decided that the site is now beyond using database caching. The server now responds extremely quickly.

If you are experiencing an extremely slow loading connection before the site loads the page very quickly, try disabling database cache in W3. I has solved an issue that my hosting and the general public when asked about it couldn’t assist on. Everything from moving to nginx, reconfiguring apache, php , mysql to handle it better. Increase server resources, it was all tried but the errors persisted. This solved it permanently.

Leave a Reply