Internet - Friday, September 17, 2010 20:44 - 0 Comments

WordPress is one of the great wonders of free software, an unlimited number of features and plugins that will keep anyone happy. With a zillion developers working on this thing it must be the best most optimized software in the world right? .. Unfortunately that is not the case. there are a few issues with wordpress that unless you are running a really low traffic site on some decent hardware you are going to start seeing performance issues with page loads and general just crashing your site (with us on a Xeon system it happened around 5000 Uniques a day). So what is the problem with wordpress? we will cover the three big ones:

1) Because there is no body managing the plugin development basically any dog and their cat can write a plugin and have it published on the wordpress site and just because this person can write a plugin.. doesnt mean it is good.

2) WordPress is ultra ultra ultra (did I put enough ultras in there yet?) Database intensive.. every little thing it does it needs to query the database.. soemtimes I wonder.. did this really need a database call? In total one one of my sites having 34 plugins and a customized template we where doing over 500 DB queries on some page loads (sometimes more)

3) WordPress takes up a huge amount of memory per page load do you want to know how taxing wordpress is on your system? download the WordPress system health plugin to find out, I was 10001% amazed when I found out that Rendering Dashboard (index.php) was taking up almost 50MB worth of memory.

So what can we do about all this? Lucky enough for the readers at this site I am willing to share my knowledge of how we saved one of our websites from constantly crashing our server with as little as 5000 uniques a day (really thats not that many hits to be crashing servers).

Caching

Basically caching is going to be one of your saviors in optimizing your wordpress. there are quite a few wordpress caching products out there but I tend to stick to the true and blue ones that have worked for me all this time:

﻿wp-super-cache: Basic settings are fine, make sure you use the ON feature and check the boxes for “Don’t cache pages for logged in users.” and “Cache Rebuild”

wp-widget-cache: Yes Widgets also need to be cached, nothing special here but I generally use the auto expire checkbox.

db cache reloaded: I expire my DB cache every 5 minutes but if you have a pretty low traffic site you can probably cache for longer.

PHP Optimization

If you are the admin of your own server I suggest installing a PHP optimizer/accelerator such as Zend or APC. I had much better luck with APC then I did with Zend and it took my page loads from close to 50MB to 15MB, thats a huge optimization. Im not really going to show you how to install APC here but if I have time tonight ill write another quick article on howto install it on Linux Centos.

Your template code

If you are a coder or know your way around html pretty good you can help your wordpress by going through your teplate code and taking out anything that is doing a database query that doesnt need to, a prime example of this is the header.php file:

<meta http-equiv=”Content-Type” content=”<?php bloginfo(‘html_type’); ?>; charset=<?php bloginfo(‘charset’); ?>” />

this can be just a static line like this:

<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />

More Admin stuff: Optimizing Apache

I have found this apache configuration to be the most optimal for my server, im not going to go into much detail here but basically edit your httpd.conf file if you have admin rights to your server:

KeepAlive On

MaxKeepAliveRequests 200

KeepAliveTimeout 5

<IfModule prefork.c>

StartServers 50

MinSpareServers 15

MaxSpareServers 30

#ServerLimit 512

MaxClients 256

MaxRequestsPerChild 0

</IfModule>

<IfModule worker.c>

StartServers 20

MaxClients 256

MinSpareThreads 25

MaxSpareThreads 75

ThreadsPerChild 25

MaxRequestsPerChild 0

</IfModule>

Comment out some modules in Apache if you are not using them:

#LoadModule ext_filter_module modules/mod_ext_filter.so

#LoadModule expires_module modules/mod_expires.so

#LoadModule headers_module modules/mod_headers.so

#LoadModule usertrack_module modules/mod_usertrack.so

#LoadModule dav_module modules/mod_dav.so

#LoadModule status_module modules/mod_status.so

#LoadModule info_module modules/mod_info.so

#LoadModule dav_fs_module modules/mod_dav_fs.so

#LoadModule speling_module modules/mod_speling.so

#LoadModule userdir_module modules/mod_userdir.so

#LoadModule proxy_module modules/mod_proxy.so

#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

#LoadModule proxy_http_module modules/mod_proxy_http.so

#LoadModule proxy_connect_module modules/mod_proxy_connect.so

#LoadModule cache_module modules/mod_cache.so

#LoadModule disk_cache_module modules/mod_disk_cache.so

#LoadModule file_cache_module modules/mod_file_cache.so

#LoadModule mem_cache_module modules/mod_mem_cache.so

#LoadModule version_module modules/mod_version.so

Optimizing MySQL

log-slow-queries = /var/log/mysql-slow.log

long_query_time = 1

key_buffer = 256M

max_allowed_packet = 1M

join_buffer_size = 4M

sort_buffer_size = 16M

net_buffer_length = 8K

read_buffer_size = 4M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 16M

max_connections = 250

max_user_connections = 128

table_cache = 256

tmp_table_size = 32M

max_tmp_tables = 128

thread_cache = 40

query_cache_type = 1

query_cache_size = 32M

query_cache_limit = 2M

thread_concurrency = 8

thread_cache_size = 8 ')}

Article written by MyComputerAid.com