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:
require_once("class.tarzan.php");
Create a new domain and verify that the call succeeded:
$SDB = new AmazonSimpleDB();
$Res = $SDB->create_domain("my_domain");
if ($Res->isOK())
{
// Succeeded
}
else
{
// Failed
}
Store some items (error checking omitted to keep this post brief):
$Item1 = array("Name" => "Jeff", "Sex" => "M", "Age" => 49);
$Item2 = array("Name" => "Carmen", "Sex" => "F");
$Items = array("Jeff" => $Item1, "Carmen" => $Item2);
$Res = $SDB->batch_put_attributes("my_domain", $Items, true);
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":
$Res = $SDB->select("select * from my_domain where Sex='F'");
The select method returns an object of type TarzanHTTPResponse. Digging in to this object is as simple as referencing $Res->body->SelectResult->Item:
foreach ($Res->body->SelectResult->Item as $Item)
{
print_r($Item);
}
The item is an object of type SimpleXMLElement. Here's what it looks like:
SimpleXMLElement Object
(
[Name] => Carmen
[Attribute] => Array
(
[0] => SimpleXMLElement Object
(
[Name] => Name
[Value] => Carmen
)
[1] => SimpleXMLElement Object
(
[Name] => Sex
[Value] => F
)
)
)
Here's how to access the SimpleDB attributes of the item:
foreach ($Res->body->SelectResult->Item as $Item)
{
print("Key: " . $Item->Name . ":");
foreach ($Item->Attribute as $Attribute)
{
print("(" . $Attribute->Name . ": " . $Attribute->Value . ")");
}
print("\n");
}
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.
-- Jeff;




Will SimpleDB be available in Asia(India) in the near future?
Posted by: Rohit Arondekar | October 02, 2009 at 05:51 PM
You know, it's all well and good, but when (last year) I tried to run SimpleDB from a machine hosted not in Amazon data center, the performance was abysmal. I was clocking responses at 300 ms. I had to discontinue use.
Posted by: chrismahan.blogspot.com | October 04, 2009 at 04:57 AM
I am a user of SimpleDB for the last while and I find it great. We could do with a few more requests most specifically an Update and Delete SQL style command, a JOIN would be really cool too but over all it's really is easy to use and if you're using EC2 is an absolute must as the datastore as you have no load balance issues and it's super fast. We also cache loads of the common requests and we have yet to pay a penny for it (since it went free anyway) which is mad.
Well that's been my experience anyway
Rob
Posted by: Robert Doyle | October 04, 2009 at 01:49 PM