Friday, August 20th 2010


Magento Site Performance
posted @ 8:57 am in [ Apache -Fixing Things -Hosting -Magento -Media Temple -PHP -Technology -Web Design ]

Magento the nice Community Version available e-commerce platform that we are using at Skywire for a number of our client builds is incredibly feature rich, but with all of these features comes the trade-off that to get any kind of speed out of the system you either need SERIOUS server hardware, or an awful lot of performance tuning.

To be honest it can run like a real dog if you don’t really work at it!

Well we like to make things work hard at Skywire so went on a journey of discovery on how to make Magento fly, and here’s our understandings to share with everyone else.

1. Server software selection and tuning

Lots of articles out there about this around the web, but you can sum it up in a few points really.

– What webserver (Apache vs. Lighttpd vs. Nginx) and how many threads for that webserver you need. Interestingly, against every article out there, Apache 2 was faster for us that Lighttpd and NginX but I think this was to do with the PHP CGI access the other two were using being slower on our Media Temple server

– Fine tune your mySQL database – we found that the two great scripts mysqlreport and mysqltuner are your friends here

– Get rid of any other processes you don’t need that get in the way (xinetd, spam assassin etc.)

2. Turn on lots of Caching

Magento has caching so turn that on for starts, and then get a minify type plugin (there’s lots of them out there but ) to complement that and join all of your CSS and JS into a single compressed file.

Install a PHP Byte Code caching system to cache any code generated by PHP – we used XCache as it was available via yum but eAccellerator gets good reviews too [although it just hung in our environment].

3. Turn on the Page Compilation feature in Magento!

Yes, I know it’s labelled as Beta, and yes I know it falls over most of the time you run it, but if you run it from the command line, as the same user that owns your web files then it works just great creating a new single directory in /includes/src containing flattened files of all your Magento files with the naming format directory_directory_etc_filename.php

This shaved at least 1 second off of every page load for us (amazing but true) however was a job to install as it ignores any modules installed in /app/code/community.

No worries though, you can work around this by just copying the whole module directory to the /app/code/local directory and rerunning the compiler and then it works great.

4. Load you Magento cache directories into a memory filesystem

Sounds a strange thing to do but you can load your /var/cache/ directory into a memory based ‘tmpfs’ which makes it much faster. Also you can move your sessions to your database instead however this slowed things down for us so we left them as files.

Summary:

So once you’ve done this on a mid-spec Media Temple DV server you can reduce page times from about 10 seconds down to just over a second, which believe me seems fast compared to how clunky Magento can be when running. Have fun!

References:

Magento performance and optimization

http://www.magentocommerce.com/group/view/168/

How do I use the inbuilt magento profiler to see bottlenecks?

http://www.magentocommerce.com/group/blog/action/viewpost/1405/group/168/

Magento Compiler – Improve your performance

http://www.magentocommerce.com/group/blog/action/viewpost/1243/group/168/

9 Methods to Speed Up Magento – A Guide to Making Magento Faster

http://www.blastedthing.com/magento/questions/mag-9-methods-to-speed-up-magento-a-guide-to-making-magento-faster/

Magento performance hosting

http://yoast.com/magento-performance-hosting/

Magento Site Performance Optimization

http://www.yireo.com/tutorials/magento/magento-spo#compress-output-in-general

Performance is Key! – Notes on Magento’s Performance

http://www.magentocommerce.com/blog/comments/performance-is-key-notes-on-magentos-performance/




Tuesday, October 20th 2009


Plesk error 500 and [apc-error] apc_mmap: mmap failed: No space left on device
posted @ 10:55 am in [ Media Temple -PHP -Technology -Web Design ]

Upgrade Plesk 8.0.3 to Plesk 9.0.x on a Media Temple DV server and it dies 🙁

Error 500, nothing in the log files, no where to turn.

Anyways… after a chunk of digging around the problem is to do with running out of memory on the container that Mediatemple allocate for the DV server.

So… you can fix it by lowering the PHP memory requirements in the Plesk 9 PHP.ini file


cd /usr/local/psa/admin/conf/
vi php.ini

Then the setting you want to change is apc.shm_size from the default setting of 40 (Mb?) to 10


apc.shm_size = 10

And then check Plesk to see if it is working


/usr/bin/sw-engine-cgi -c /usr/local/psa/admin/conf/php.ini -d auto_prepend_file=auth.php3 -u psaadm

..and with a bit of luck you should be away! More details in a good discussion on the Plesk forums here




Friday, October 16th 2009


Upgrading Plesk 8.3 for PCI compliance to 9.x
posted @ 3:53 am in [ Fixing Things -Media Temple -Web Design ]

PCI compliance … grrrr… understand why it needs to be done but crikey is it a boring process to do.

Anyway, turns out that Plesk 8.3, the default from our lovely hosting provider at Media Temple, isn’t PCI compliant as it uses an old Apache install

However, never fear, easy fixes at hand 🙂

Upgrade 8.3 to 8.6
/usr/local/psa/admin/sbin/autoinstaller --select-release-id PLESK_9_2_2 --upgrade-installed-components

Upgrade 8.3 to 9.0 (latest)

/usr/local/psa/admin/sbin/autoinstaller --select-release-latest --upgrade-installed-components

or you can run the upgrade interactively using just

/usr/local/psa/admin/sbin/autoinstaller




Friday, March 6th 2009


Changing the default SSL certificate in Plesk
posted @ 6:16 am in [ Fixing Things -Media Temple -Technology -Web Design ]

Plesk as provided by Media Temple on all it’s servers is great, however I do ocassionaly get the ‘where the heck is button to do that’ feeling with it and as much as I try the very feature I’m looking for is there, just hidden away.

One that has thwarted me a number of times is how to change the default SSL certificate for a domain when you install a new SSL certificate. You would have thought Domains -> Certificates, or Server -> Certificates -> Make Default would do the trick, but nope neither works.

However… if you click on Server -> IP Addresses ->  <Your IP Address> -> you get the ability to select which SSL ceriticate you want for the server et voila job done.

No if only that was easier to find (hence why the Abridged Learnings lives :-))




Wednesday, October 22nd 2008


Running Java servlets and Java application servers on Media Temple DV Servers
posted @ 5:29 am in [ Fixing Things -Media Temple -Technology -Web Design ]

I’ve always had problems trying to run Java based application servers on Media Temple Dedicated Virtual Servers (DV Servers), as although they have lots and lots of disk space and bandwidth, they seem to have very small memory spaces that you can run containers in.

Java by default powers up with about 1024Mb of memory requirements, so if you are installing Apache Tomcat (java servlet engine) or Red 5 (Open Source Flash Video server – very good, try it out) you have to seriously reign in the memory these guys try and use when powering up.

For reference the best way to achieve this is using the -Xms and -Xmx parameters, so in my case I added the following to the startup.sh script for Tomcat

JAVA_OPTS=’ -Xms128M -Xmx128M’
export JAVA_OPTS 

Ideally I’d like a bit more memory to play with, but at least it works like this and the old application I’m supporting can run 🙂




Thursday, April 10th 2008


More Media Temple D/V: Installing YUM (Yellow dog Updater, Modified)
posted @ 7:08 am in [ Media Temple -Technology -Web Design ]

I know I said below that you can just Google how to do this, but then I had to do it again today on a client’s server, and actually nobody has the correct instructions for the 4.5 version of CentOS that is installed on Media Temple Dedicated Virtual servers (D/V) by default.

So, the basic principle is that YUM needs sqlite, the sqlite libraries for python, a few other python things like elementtree and urlgrabber and then YUM itself. Grab the libraries you want from the CentOS vault and then install them (you need to get your root password for this – control panel request the lovely people at M/T if you don’t have it) and the rest should be easy….

export MIRROR=http://vault.centos.org/4.5/os/i386/CentOS/RPMS/
wget ${MIRROR}python-sqlite-1.1.7-1.2.1.i386.rpm
wget ${MIRROR}sqlite-3.3.6-2.i386.rpm
wget ${MIRROR}python-urlgrabber-2.9.8-2.noarch.rpm
wget ${MIRROR}python-elementtree-1.2.6-5.el4.centos.i386.rpm
wget ${MIRROR}yum-2.4.3-3.el4.centos.noarch.rpm
wget ${MIRROR}libxml2-python-2.6.16-10.i386.rpm
wget ${MIRROR}rpm-python-4.3.3-22_nonptl.i386.rpm

rpm -Uvh python-elementtree-1.2.6-5.el4.centos.i386.rpm
rpm -Uvh python-urlgrabber-2.9.8-2.noarch.rpm
rpm -Uvh sqlite-3.3.6-2.i386.rpm
rpm -Uvh python-sqlite-1.1.7-1.2.1.i386.rpm
rpm -Uvh rpm-python-4.3.3-22_nonptl.i386.rpm
rpm -Uvh libxml2-python-2.6.16-10.i386.rpm
rpm -Uvh yum-2.4.3-3.el4.centos.noarch.rpm

Bing! YUM ready to roll and add all those other things you need (for us were installing MySQL 5 so that we can have VIEWs :-))