A Non-Traditional Wordpress Tuning Guide Part III

September 1, 2008 by  

Notice: I take no responsibility for the code mentioned in this, or other, blog posts. This code works on my site, however, I will not guarantee nor be responsible for how it runs in your hosting environment.

If you’re using a php accelerator, in particular, if you’re using APC PHP Accelerator, your Wordpress Blog can receive a distinct performance boost. Since Wordpress uses PHP with a mySQL backbone, optimizing PHP and/or mySQL will result in a faster Wordpress Blog.

PHP Accelerators

  • A PHP Accelerator focuses on optimizing PHP by caching the compiled output of PHP code. In other words, when using a PHP Accelerator, a page using PHP code does not need to recomple on every page request — just when something in the code changes. This saves CPU time, and helps a server to render information faster.

I came across an interesting PHP file that uses APC as the backend for the WP Object Cache v0.2. On this website, I’m using v0.2.1. To be honest, I have not done a file comparison between v0.2 and v0.2.1 in order to see the differences — all I know is that v0.2.1 works on this site with the latest version of APC, v3.0.19.

Remember to view the information contained in the file. It says, “Install this file to wp-content/object-cache.php

I recommend enabling the number of mySQL queries before installing this APC Plugin for Wordpress. This code might be useful for this purpose:

<p style=”margin:0;padding:0;”><?php echo get_num_queries(); ?> <a rel=”nofollow” href=”http://www.mysql.com/”>mySQL</a> queries executed in <?php timer_stop(1); ?> seconds.</p>

What you should see is a reduction of the number of mySQL queries when your blog page/post is refreshed. Of course, all of this assumes that you have the Query Cache enabled in mySQL.

MySQL’s my.cnf

  • [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    skip-locking
    skip-innodb

    back_log                 = 50
    connect_timeout          = 1000
    concurrent_insert        = 4
    interactive_timeout      = 1000
    join_buffer              = 3M
    join_buffer_size         = 3M
    key_buffer               = 192M
    log_slow_queries         = /var/log/mysqld.slow.log
    long_query_time          = 1
    low_priority_updates     = 1
    max_allowed_packet       = 1M
    max_connect_errors       = 15
    max_connections          = 150
    max_heap_table_size      = 128M
    max_tmp_tables           = 1024
    max_user_connections     = 150
    myisam_sort_buffer_size  = 128M
    net_buffer_length        = 16k
    query_alloc_block_size   = 16384
    query_cache_limit        = 2M
    query_cache_min_res_unit = 1k
    query_cache_size         = 48M
    query_cache_type         = 1
    query_prealloc_size      = 64M
    read_buffer_size         = 2M
    read_rnd_buffer_size     = 4M
    record_buffer            = 3M
    server-id                = 1
    skip-bdb
    skip-innodb
    sort_buffer_size         = 2M
    table_cache              = 1024
    thread_concurrency       = 4
    thread_cache             = 128M
    thread_cache_size        = 40
    thread_stack             = 128K
    tmp_table_size           = 128M
    wait_timeout             = 60

WordPress’s wp-config.php

  • define(’WP_CACHE’, true);
    define(’CACHE_EXPIRATION_TIME’, 900);

Comments

You are welcome to contribute comments, but they should be relevant to the post and the conversation that ensues. To keep comment exchanges focused and engaging, we reserve the right to delete off-topic remarks and self-promotional URLs - so please avoid these.
We recommend that comments be a minimum of 3 sentences long.