Don’t Forget: You Can Use Amazon SimpleDB For Free!
We polled the attendees at a recent Amazon SimpleDB webinar and found that over half of them didn’t know that they could start using the service for free. That’s a shame because SimpleDB is easy to use, scales easily to handle high request rates, and is available in our US and EU regions.
You can keep up to 1 gigabyte of data in SimpleDB without paying any storage fees. You can transfer 1 GB of data and use up to 25 Machine Hours to process your queries each month. This should be sufficient to allow you to issue about 2 million PutAttribute or Select calls per month.
We have pages of SimpleDB sample code and libraries, plenty of SimpleDB articles and tutorials, and some really good SimpleDB documentation.
I’ve spent the last couple of months writing a book on AWS programming (to be published by SitePoint later this year) and I had a lot of fun with SimpleDB. The book is targeted at web developers, so I wrote all of the code in PHP and used the Tarzan toolkit (soon to be renamed Cloud Fusion). I had fun creating examples to show how to store RSS feeds, AWS usage information, and EBS snapshot metadata in SimpleDB.
Here are some examples of just how easy it is to store and retrieve data using SimpleDB, PHP, and Tarzan.
The first step is to include the class file:
Create a new domain and verify that the call succeeded:
Store some items (error checking omitted to keep this post brief):
In this example I took advantage of SimpleDB’s flexible schemaless model to avoid disclosing my wife’s age.
Here’s how to retrieve all items with Sex set to “F”:
The select method returns an object of type TarzanHTTPResponse. Digging in to this object is as simple as referencing $Res->body->SelectResult->Item:
The item is an object of type SimpleXMLElement. Here’s what it looks like:
Here’s how to access the SimpleDB attributes of the item:
What you can’t see from the code, but which is important nevertheless, is that this code, if used at the core of a busy application, can handle thousands of storage or retrieval requests per second without any additional effort on my part. In addition, I don’t have to worry about hardware failures, replicas, full disks, improper indexing, and so forth. I can focus on my application and on meeting the needs of my users.