How to cut down wordpress memory usage.

Photogabble is similar to many other websites in that it is managed via an installation of word-press; word-press by and large is a very good blogging platform, indeed I would say it is one of – if not – thee best blogging platform available today quite simply for its simplicity, its script-ability and ease of designing for. However there is one draw back, as with everything around us, wordpress is not perfect; indeed the average install alongside its additional plug-ins and add-ons seems to consume copious amounts of system memory which is bad! While I am lucky to have built my server from scratch it still has limitations the most important of which being memory, a whole 2GB of it.

Up until I completed the following quick fix, wordpress was using almost 30MB per instance, this means that I could only at peak have 66 or so visitors at the same time before my server became overrun and hid under the bed. What I needed to do was supercharge php and the easiest way to do that is by caching. Thanks to this interesting article on php caching by itst.net I chose APC (Alternative PHP Cache) which is supported by the php foundation and showed the most promising speed improvements.

Installing APC really couldn’t have been made any easier on debian; it does require some dependencies, obviously php 5.x plus the pear package installed but apart from that not much else is needed to be installed and it you use apt-get they are installed as part of the installation process. The instillation process is as simple as follows:

apt-get install php-apc

/etc/init.d/apache2 restart


Once APC has been installed and apache restarted you can issue the following command to ensure that it has installed correctly:

php -r 'phpinfo();' | grep apc

Once that has been done and you get a positive response to the above command you should see that wordpress is using considerably less memory. My install with its 16 or so plugins now uses 3.16MB rather than almost 30MB! That is what you call a good improvement.

One draw back with apc as with many caching processes is that it does cause an initial increased draw on the processor while it compiles the php into an performance enhanced executable file and stores it in a ram disk however once this intial process it done you can stand to see upto 200% increase in performance and a severely reduced memory footprint for each of your php apps.

One Response to “How to cut down wordpress memory usage.”

  1. [...] grave problema che affligge wordpress a partire dalla versione 2.8 come:Wordpress is a Memory Hog,How to cut down wordpress memory usage,PHP on Fire: Five Opcode Caches compared,Wordpress and Server RAM: Your (many) Plugin Uses (much) [...]

Leave a Reply