After completing my work with the new search class I’ve moved onto something completely new to me. I’ve been doing some tests with Amazon Web Services to decide if S3 and EC2 would be a viable alternative to running our own image server with multiple terabytes of storage plus redundancy. So far I’m very pleased with the performance I’m seeing.
I’ve pieced together a PHP class that meets all our needs for pushing and pulling files from S3. I have all the raw functionality in place and now I’m working on response parsing, error checking, and redirection detection. There are plenty of prebuilt PHP S3 solutions out there, but I’m a bottom up type learner, so building this class was the best way for me to learn how to use S3.
After looking at the alternatives and doing some math I’ve built the class using the HTTP_Request pear package for transmitting of files over HTTP via REST. The overhead of passing authentication headers with every file still seems the be preferable to the size of a SOAP envelope. In some informal benchmarking I’ve found I can reliably transfer small files at between 50 and 60kbps. This is ample for the small number of file we’ll be uploading directly from our web server directly to S3. Most of our uploading will be done via an EC2 instance which is much faster.
I also found a firefox extension called S3Fox that allows me to interact with S3 as if it were an FTP server. This will allow me to easily keep an eye on things as is sometimes necessary when automated processes go awry. It’s also been helpful in some early testing to know that my code runs at least as efficiently (if not slightly more so) when uploading objects as this extension does.
The next part of the plan was setting up an EC2 server. I instanced my first server this morning and made enough changes to the base apache-mysql image so that I’ll be able to start installing code next week. The process of instancing an EC2 server is a little conveluted at first, but as soon as all the tools are in place maintenance is a breeze. It also very easy to export server images once you get things set up the way you want them. That will allow us to have all our code and settings in place as soon as the instance launches. I ran the same informal small file benchmark from the EC2 server that I mentioned above and I got well over 200kbps of upload speed. Larger files will also run faster due to the per file header and response overhead.
All-in-all I’m very satisfied with the way things are working out. Hopefully it won’t take me too many more code hours to get a bullet proof system in place to reliably use AWS as our image solution. Though in terms of days there may be some time before I can activly start moving existing images over as next week we’re going to be bringing a new versioning and ticketing system online on our sandbox.