WP Ecommerce optimisation on AWS EC2 micro instance

Overview

Have recently moved over to Amazon Web Services' EC2 micro instances for all our hosting, and so far the experience has been fantastic, the speed of deployment and rapid development is just awesome.

Saying that, the performance of running not-so-compact content management systems such as Wordpress and ExpressionEngine out of the box has been less then stellar on the micro instance (free tier) which is to be expected. 

Below I have included some steps taken to improve the speed of our WP Ecommerce build for the Caku online store.

First thing's first, Apache

Here are the tweaks made to the Apache config file (/etc/httpd/conf/httpd.conf).

MaxKeepAliveRequests 80
KeepAliveTimeout 15

StartServers          2
MinSpareServers       2
MaxSpareServers       6
MaxClients           10
MaxRequestsPerChild   300

AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript

PHP optimisation

Next, installing a opcode cache to speed up PHP performance (APC) with the following steps:

yum install php-pear
yum install php-devel 
yum install httpd-devel 
yum install gcc make 
yum install zlib-devel 
yum install pcre-devel  

pecl install apc

To reduce process bottlenecks while working in the admin console, I recommend increasing the memory limit in /etc/php.ini.

memory_limit = 512M

It also helps to install memcache daemon to improve web app's object caching.

yum install memcached  
pecl install memcache

Now, add the extra modules to PHP config and restart Apache

echo "extension=apc.so" > /etc/php.d/apc.ini 
echo “extension=memcache.so” > /etc/php.d/memcache.ini  

service httpd restart

Wordpress configuration

We used the excellent W3TC Wordpress plugin for managing cache controls for site elements. Our config is pretty standard, with minimising of CSS,HTML and JS files.

WP Ecommerce category specific content blocks

To create a category specific content block in WP E-commerce single product template (in our context, outputting a unique sizing chart link depending on whether the user navigates to mens or womens clothing sections) is fairly straight forward.

For each product, all category data can be retrieved via get_the_product_category() which outputs an array of categories. A basic example for wpsc single product template implementation would be:

$cat_list = get_the_product_category(wpsc_the_product_id());
if ($cat_list[1]->name == "mens"){ 
//DO STUFF
}