Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5540

Mike Bijon on "Too many MySQL connections and MySQL server has gone away"

$
0
0

@sondogtech, your recommendations for optimizing the database are right on, but are you advocating for @Kate to not even consider an object cache or plugin?

The best performance results should actually come from using all 3 options.

DB Optimization
@sondogtech's DELETE query will work, but it can lead to mistakes if you run manually. Instead grab @dd32's Revision Control plugin & it will limit revisions permanently: http://wordpress.org/plugins/revision-control/

I'd recommend tools.percona.com to get you started too. I start with their configs all the time: https://gist.github.com/mbijon/4701099

Caching Plugins
Most caching plugins now create large sets of .htaccess rules if you have an Apache-based web server. Using .htaccess rules & cached static content the plugins prevent themselves or PHP from loading very often (static file serving is actually far more efficient than anything my.cnf can do). Grab W3 Total Cache or Super Cache for good general-purpose plugins that work well on Apache servers:
* http://wordpress.org/plugins/w3-total-cache/
* http://wordpress.org/plugins/wp-super-cache/

(Note: Logged-in users and Admins will always skip the caches, so a site running Buddypress, a forum, or even P2 comments may not be that much faster with these plugins)

Object Cache
Object Caching both reduces your DB query-count and prevents large chunks of PHP that handle query results from running. In this manner it uses "some PHP" to run less PHP ... and can deliver a big speedup.

Installing memcache or APC is pretty simple for most sysadmins & there are a ton of great articles about how to do it for WordPress.

Hybrid Systems (aka: All of the Above)
I recommend using all the above options, but unless you can be patient, start with plugin & object caching. DB tuning tends to be more time consuming, especially since the WP core team has done a great job of optimizing everything really well already.

For an example of hybrid caching boosts, the Batcache plugin is the core of what they use on WordPress.com, and combines a page cache with object cache for about a 4,000% speedup (A site I use it on was hit by frontpage Reddit traffic last month & the 2CPU web server + 4 CPU DB server spiked over 800 requests/sec with page generation under 900ms the whole time).

If you want something even faster, switch from Apache to nginx. It requires a lot more setup time, but enables microcaching by the webserver (which takes the DB & PHP out of the loop): http://markjaquith.wordpress.com/2012/05/15/how-i-built-have-baby-need-stuff/.

Another WP core contributor wrote a great post about using nginx & Redis caching to serve pages in under 5ms, http://eamann.com/tech/ludicrous-speed-wordpress-caching-with-redis/. We run a very similar set at another client of mine & can handle about 8,000 req/sec across 5 severs. And I'd estimate that on a single dedicated server you can probably spike over 1,000 req/sec with a similar configuration.


Viewing all articles
Browse latest Browse all 5540

Trending Articles