OpenX Blog

Testing with Amazon EC2

Tags: Developers
by David Keen on July 6th, 2007

Openads supports a large number of different software configurations that range from PHP 4.3 and MySQL 4.0 to the latest PHP 5.2 and MySQL 5.0. In order to make sure Openads works perfectly on these different platforms we need to test on each one.

Our build server runs CruiseControl and every night it runs our test suite against thirty different PHP/MySQL combinations. This alerts us to any code changes that may have broken compatibility with one or more versions of PHP/MySQL.

But once we find a bug in a particular version how do we fix it? To save each developer having to have five different PHP versions and three different MySQL versions installed on his development machine we use Amazon’s EC2 service to start and stop particular server configurations on demand.

The Amazon Elastic Compute Cloud (EC2) is part of Amazon Web Services and is currently in private beta. It provides the ability to start and stop a (theoretically) unlimited number of virtual servers as your demand dictates.

Using EC2 is easy. All you need to do is:

  • Create an Amazon Machine Image (AMI) containing your application and server settings - you can build your own image from scratch or use one of the pre-configured public images.
  • Upload the AMI into Amazon Simple Storage Service (S3).
  • Start as many instances of your server as you need!

The great thing about Amazon Web Services is that you only ever need pay for what you use. So if we just need to run some tests on a server configured with Openads running on, say, PHP 4.4.7 and MySQL 4.1.22, we simply fire up an EC2 instance for an hour or so and it costs us less than $1.

We have EC2 images prepared for every combination of PHP/MySQL we support and using Zend’s remote debugging facility we can debug on any of about thirty or so software combinations.

Amazon provide command-line tools for starting and stopping EC2 instances but here at Openads we use RightScale to manage our EC2 instances. The RightScale console not only makes it easy to start and stop instances but it also makes it possible to share your account with others without having to disclose your secret AWS access keys. There are fairly fine-grained permissions so you can invite someone to use your EC2 account and then, say, only allow them to view their own instances. You can also revoke permissions at any time.

Not only can you start and stop instances from RightScale, but they also provide a bunch of really useful features like monitoring graphs, auditing and an integrated S3 browser. But perhaps the most useful feature is the web-based SSH console. This means if you start an instance with your SSH key you just need to click on the SSH Console link to open up a terminal on the running instance - no passwords required!

At the moment RightScale is in beta and is free to use. If you already have an EC2 account then you just add your AWS credentials and continue paying Amazon as usual. But even if you don’t have an EC2 account yet you can still try it out as RightScale offer a “sub-account”. You use their “master account” to get EC2 resources and Amazon bill them for your usage. RightScale even throw in 10 hours of free EC2 instance time to get you started.

10 Comments »

  1. Any plans to release your PHP/OpenAds AMIs?

    Comment by David Cancel — July 7, 2007 @ 12:20 am

  2. Releasing public AMIs may be something we do in the future although at the moment our images don’t actually include the application. This is because we will usually want to test the latest version of the code so it is a simple matter to check it out of subversion each time. I have set up a database and user for the application on the image so this doesn’t need to be created each time.

    Basically, our procedure for launching a test instance is:

    * Launch AMI with desired PHP/MySQL combination
    * Start SSH terminal
    * Checkout the latest code from subversion
    * Start Apache and MySQL
    * Test!

    We can set up a dedicated testing instance of Openads in a few minutes.

    Comment by David Keen — July 7, 2007 @ 10:22 am

  3. Hey there,

    I’ve never thought of using EC2 for debugging and plattform testing - not sure how I missed that earlier. Way to go on effeciency!

    Also, since you blogged about the plattform support, are there any plans to join GoPHP5 (in the long run)? I think OpenAds would benefit from PHP5-only code. Thoughts?

    Cheers,
    Till

    Comment by till — July 8, 2007 @ 7:58 pm

  4. GoPHP5 is an interesting idea and I think people should definitely be encouraged to move to PHP5. Personally, I’d love to be able to write PHP5-only code but as the latest PHP stats for June show, over 80% of PHP sites are still stuck on PHP4.

    This is a real problem for the PHP community.

    Comment by David Keen — July 10, 2007 @ 8:27 am

  5. Hi there,

    For us EC2 account holders, it would be great to have an AMI that runs openads 2.3 configured for testing purposes or even for production.

    Please tell me you can share at least one AMI for this.

    Thank you,
    Alexander

    Comment by Alexander — July 10, 2007 @ 9:03 pm

  6. Are you thinking of including an option to upload banners to S3, rather than into the database? Would be a great feature, imho.

    Comment by Jan — July 11, 2007 @ 1:11 pm

  7. I agree, an S3 storage option would be a good feature! In fact, it is something I have been thinking of implementing ever since I started playing with EC2 and S3…

    Comment by David Keen — July 12, 2007 @ 7:36 pm

  8. As I mentioned in a previous comment, releasing public Openads AMIs may be something we do in the future.

    In the mean time, if you want to take Openads for a test drive you can always try our online demo.

    Comment by David Keen — July 12, 2007 @ 7:40 pm

  9. Just a question - could you post a list of modules needed to run openads? Like a very stripped down PHP optimized to run nothing but OpenAds? (Also, is there a comment notification here? ;-))

    Comment by till — August 13, 2007 @ 12:45 pm

  10. [...] I liked the Java University session I had with Chris Richardson so I thought I would attend his talk on using EC2 for testing. He’d obviously read my previous post as he made a reference to me calling his accent “mutant”. Chris, I hope I didn’t cause offense! After introducing AWS and EC2 his talk was mainly about his open source framework called Cloud Tools which is a framework written in Groovy that’s used for deploying and testing Java apps on EC2. It was interesting, especially considering we’ve been using EC2 for testing at work for quite a while now. [...]

    Pingback by frogcake.net » JavaOne Day 2 — May 8, 2008 @ 1:03 am

RSS feed for comments on this post. TrackBack URL

Leave a comment