The best WordPress performance tip, ever.

If you’ve ever used WordPress to host a blog than you know that it is a very powerful platform. With a lot of power comes a lot of complexity. This complexity combined with the mandate that WordPress be easy to use/install/run combines to make for some interesting choices as it pertains to performance.

Recently I was tasked with building a high performance WordPress system for a user. I won’t bore you with all of the details but I will give you 1 tip that saved the day for me.

For whatever reason WordPress uses MySQL queries that write temporary tables, because these temporary tables include fields that cannot be cached/stored in memory; these temporary tables must be written to the hard disk. Anyone who has studied modern computer architecture knows that the largest bottleneck in any system is IO.

If you are running Linux You may have noticed in the past that newer Linux servers come with a partition called /dev/shm (or shared memory). This is essentially a ram disk (or storage in RAM) that your system provides to you to use (or not use) as you see fit.

You can verify that this partition exists by using the following command:

df –h

Filesystem            Size  Used Avail Use% Mounted on
                      257G   42G  202G  18% /
/dev/sda1              99M   19M   75M  21% /boot
tmpfs                  12G  4.0K   12G   1% /dev/shm

If you see a tmpfs partition mounted on /dev/shm you are good to go.

If not your OS distribution may have named it something else, so check with the manual or contact me for more information.

If this partition exists, you can instruct MySQL to use it as storage for your temporary disk based tables by editing your MySQL configuration file (usually located in /etc/my.cnf) and adding this line:


Then restart MySQL.

Using this one tip I was able to increase the performance of my WordPress server by over 500% and it was the most effective optimization I did in terms of performance gains. It was better than adding SAS disks in RAID-10 and other very expensive hardware upgrades.

I hope this helps you!

Be Sociable, Share!

Tags: , ,

Leave a Reply

You must be logged in to post a comment.