Friday, December 31, 2010

Magento on Rackspace CloudServers

Warning: Moderately Technical Post Ahead.  Read With Caution.

If you've tried Magento, you know that it can be dang slow.  Especially versions prior to 1.4.  I don't know what the heck they're doing with all those CPU cycles, but Magento sure eats them up.

Enter the Rackspace Cloud.

In an attempt to improve the performance of my dual quad-core AMD64 HP web server (yes, 8 CPUs) and the 15k SCSI drives in my database server, I started testing out a couple of my Magento sites on the Rackspace Cloud solution.  The results have been somewhat remarkable - but not without a bit of work.

My experience has shown that in order to run a Magento site and the MySql database behind it on the same Rackspace CloudServers instance, you really need a 1GB instance or larger.  I have tried the smaller instance sizes, but they quickly run out of memory and go to swap, which makes the situation even worse than my shared servers.

With a 1GB instance, there is ample disk space for my site and database with over 5,000 SKUs.  The I/O throughput appears to be at least as good as my 15k SCSI hardware RAID1 configuration on an HP DL360.  In fact, I am pretty confident it is actually better.  And while Rackspace is very "cloudy" about the amount of CPU that a particular instance is allocated, nothing appears to become CPU bound on my installations.

Here are a couple of recommended optimizations if you are planning to run Magento and MySql on CloudServers from Rackspace:
  1. Turn on Query Caching for MySQL.  I generally set the max size of the QCache to about 1/3 of the total system memory.  Going larger than that will eventually result in using swap and slow everything down to a crawl.
  2. Install APC for PHP.  This makes a huge difference for Magento.  Again, I set the memory limit for the APC cache to around 30% of system memory.  I have found that different sites will use dramatically different amounts of the APC cache, so monitor your own usage and adjust the maximum allocation accordingly.
The performance improvement has been dramatic moving from my 2 over-taxed servers to CloudServers.  The transition was generally smooth, and reliability has been flawless.  Add in the relatively painless option of backing up to CloudFiles and you have a nice solution for moderate-volume Magento sites at a reasonable cost, that performs well, and can scale up quickly if necessary.

One of my favorite features of Rackspace CloudServers is the ability to resize an instance in place.  If you find that you need more CPU or RAM because of a spike in demand, simply up-size your instance and perhaps adjust your cache sizes (described above).  So much better than trying to get another machine, install the OS & software, copy over the data, etc, etc.  When I have tested instance resizing, there is typically less than 5 minutes of downtime while the server is resized.  Well worth it when the server comes back online and can service the the load properly.

4 comments:

  1. I like Rackspace Cloud, it's easy to manage and very simple to spin up servers for testing or scaling. The one thing that I take issue with (and the reason I stick with Slicehost) is the control panel. Rackspace is not a startup, it's not a new company, it has no excuse for a shoddy control panel that crashes, stalls, and is plain unusable at times.

    ReplyDelete
  2. Hey Josh - Great point about the control panel. It used to be really awful. About a month ago they did a major release and it's MUCH better now, but there is no excuse for the horrible performance of the previous version. From my point of view, though, I spend less than 1% of my time dealing with the control panel once a server is running. It's the performance of the CloudServers themselves that concern me.

    Thanks for the feedback!

    ReplyDelete
  3. Thanks for the blog. I was trying Magento out by installing it with the sample data on Rackspace (512MB/20G). I was in disbelief how painfully slow it was. Good to know it improves dramatically with the 1G/40G option. Thanks.

    ReplyDelete
  4. DaGobi, You might want to check out today's post about what I've seen using CloudServers to host Magento sites: http://szettellaatrandom.blogspot.com/2011/09/magento-on-rackspace-cloud-update.html

    ReplyDelete