Daniel Watrous on Software Engineering

A Collection of Software Problems and Solutions

Posts tagged ec2

Software Engineering

Cloud hosting: Google App Engine vs. Amazon Web Services

My talented brother, Tim Watrous, has worked in the advertising industry for nearly 15 years now. His background started on the technical side, but he quickly found his strengths in the larger scope of marrying the business to a best possible advertising solution.

He and I often talk shop and tonight we got on the topic cloud computing. I mentioned some of my experience with the two most prominent platforms available, Google App Engine (GAE) and Amazon Web Services (AWS). The following details come from an email that I drafted for him to discuss these two platforms and some of the differences between them. Note that this is more high level than my previous discussion of GAE vs. AWS.

Google App Engine (GAE)

Google App Engine (GAE) is Google’s PaaS (Platform as a Service) offering. Unlike other mainstream hosting, they dictate the platform specifics and allow you to develop for it. This means it is not possible to run much off the shelf software on this platform. It is pay for use with a free quota, meaning small projects and testing are very cost effective.

Here’s a write up and video I did about GAE a long time ago:

I also have a couple of running services that live on GAE, including this one (written in python):

Recently I have published a lot on this site about using GAE for Java development.

Amazon Web Services (AWS)

Amazon Web Services (AWS) includes a growing suite of tools and technologies. Their main ‘hosting’ mechanism is EC2 (stands for Elastic Cloud Computing). This works a lot like a virtual server and can be setup in minutes. A principle difference between this and GAE is that AWS requires more consideration when deciding how the environment should be setup. There are times when that flexibility could both help and hurt a project.

AWS imposes fewer restrictions on what software you run and how you run it which makes more modern platforms accessible. Here’s an end to end example of an application that I developed and hosted on EC2 using Java and other modern technologies:
Java, Wicket and Hibernate on Amazon EC2 in a weekend

I have used the Amazon S3 (Simple Storage Service) for years now. It’s a type of content delivery network (CDN). I host files there that would consume too many resources on my main website and potentially make my site unresponsive. Most people never even know that I’m streaming video or downloading data from S3 instead of my own site because of how I define my URLs to amazon, like this video for my membership website:

Most people look at the first bit and think it’s hosted directly on wordpressmembershipuniversity.com…


I think the most common misconception most business folks have when they talk about cloud computing is the idea that it’s just a more robust or salable version of the solutions they have used in the past. In some respects that might be true. But there are some more significant differences.

Think about it like this. If you think about web hosting like a car, then you would be tempted to think about typical hosting like a little four cylinder economy car and cloud computing might seem like a V10 Dodge Viper. In reality, cloud computing is more like a build it yourself kit car and may be smaller than an economy car or larger than the biggest road car.

The importing point to be clear on is that it’s often NOT a drop in replacement for your current slow running web application.

Software Engineering

Java, Wicket and Hibernate on EC2 (pre-interview project)

Over the weekend I put together a project as a precursor to an interview. I really like interviews where I have a chance to solve a problem that’s more meaningful than generating a random number efficiently.

The pre-interview question came in the form of a sketch of the application. This worked out great since I suggest always starting with a sketch drawn by hand. Here’s what they wanted:

Choice of technology

The instructions indicated that I could use any technology that I was familiar with, as long as I included the libraries necessary to compile the code. Since I’ve been interested in Wicket lately and wanted to get into the latest version of Hibernate (it’s been a few years), I chose Java, Wicket and Hibernate.

For the development IDE I chose NetBeans due to its native support of Maven. Wicket quickstart projects base their build on a Maven pom.xml.


I started my project using the Wicket quickstart. This makes use of Maven archetypes which require Maven2+. Some development benefits that come along with the quickstart include tests that are verified at each compile of the project. This ensures, at a minimum, that your markup and Java files agree.

I used Mercurial (hg) to create a local repository to manage revision control. Even for small projects revision control is a key element and reduces the risk of big refactorings and other explorations. The hg repository can also be ‘pushed’ to anyone else that wants to collaborate on the project.

In some ways, the story that the revision history tells is as important (maybe more so) than the finished product. The revisions themselves provide valuable insight into the way a developer approaches his work.


For the database I chose HyperSQL (HSQLDB). This is a pure Java database with an in memory mode. Hibernate abstracts the database access and makes it easy to move to a more robust production database at some point in the future. HSQLDB makes development easy since the database is initialized each time I restart the jetty server.

Documentation and collaboration

TRAC is my preferred artifact tracking system for software projects. It integrates directly with Mercurial. It provides roadmap, wiki, timeline and other reporting and collaboration devices. Once I got the project to a stable point, I pushed the repository up to a public location with an integrated TRAC instance.

You can checkout the code or view it online using the URL below:


To checkout the code using the URL above just enter this command:

hg clone http://danielwatrous.repositoryhosting.com/hg_public/danielwatrous/favorite-movies favorite-movies

Once you have the code cloned to your local system as shown above, run the commands below to compile and run the application (this requires that you have Maven 2+).

mvn compile
mvn jetty:run

You should now be able to view the application at this URL:


Additional development

Next steps in the development of this application may include additional tests, better encapsulation and refined access mechanisms.

For example, aside from the default tests that are a result of the Wicket quickstart, I haven’t added any additional unittests. If the complexity of the application increased if might be worthwhile to add unittests to the Movie and RatingModel classes.

At some point data access could be encapsulated into a DAO for the Movie class. This might be beneficial if access to Movie objects spread to additional pages and those pages duplicated the code required to access those objects.


I’ve been keen to play around with Amazon’s EC2 service for a while. This seemed like a perfect opportunity, so I added EC2 to my Amazon Web Services account and created an instance. I chose 64 bit Amazon Linux. I chose Tomcat as the web server.

I added the Tomcat server running on my EC2 instance to the Maven files, which made it possible to build and deploy in a single step from the command line

mvn tomcat:deploy

As development continues I can redeploy easily using this command

mvn tomcat:redeploy


Download the source


The following resources were helpful during the development of this application:



Enum support in Java/Wicket


Amazon EC2


Wicket users list

I also found the wicket users list very helpful, as usual: