simpledb, an introduction
DESCRIPTION
An introduction to Amazon AWS SimpleDB, I gave this talk at the Ruby on Rails usergroup meeting of june 2009TRANSCRIPT
Amazon SimpleDBA quick intro
Paolo Negritwitter @hungryblank
DB
DB?
•SimpleDB
•CouchDB
•MongoDB
DB?
http://www.flickr.com/photos/zheem/3091325244/
Key Value store?
http://www.flickr.com/photos/wdwbarber/1338954161/
A bit like...
• BigTable
• HyperTable
• Redis
• TokyoCabinet
• ...
Different Shades
DB >
KV > http://www.flickr.com/photos/dey/11717609/
CommonalitiesSchema less
NOJust store your data
Commonalities
•No transactions
•No relations
•No datatypes (some)
Fast0.7 seconds to store 1 million records
http://www.flickr.com/photos/donsolo/1405885541/
(TokyoCabinet)
Big datasets
SimpleDB 1.000.000.000attributes/domain * 100 domains
http://www.flickr.com/photos/digitalart/2101765353/
Key ValueA
data
D
data
H1
data
A6
data
< Key
< Value
SimpleDB
< Key
< Value
Attribute >
}Attribute value >
AT W
data
data
SimpleDB
Nested hash of strings
SimpleDB
• Only strings
• No schema (no attribute declaration)
• up to 256 attributes per item
• EVERYTHING INDEXED
SimpleDB
• 1024 K max length
• Any UT8 character that is valid in XML docs can be used
< Key
WAttribute >
Attribute value >
SimpleDB
• 1.000.000.000 attributes per domain
• 100 domains per account
• you can have more than one account
SimpleDB
SOAP protocol<wtf>wtf</wtf>
http://www.flickr.com/photos/rescuedog/2242215507
SimpleDBOr “REST”
http://sdb.amazonaws.com/?AWSAccessKeyId=BLAHBLAH&Action=PutAttributes&Attribute.
0.Name=code&Attribute.0.Value=31&DomainName=test_domain&ItemName=bar41&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-06-07T23%3A15%3A50Z&Version=2007-11-07&Signature=...
SimpleDB
HostSimpleDB
requestREST or XML
responseXML
SimpleDB Requests
• create/delete domain
• put/get/delete (selectively) attributes
• and... SELECT
SimpleDB
• Up to 10GB big
• Up to 1.000.000.000 attributes stored
Domain: a container of (nested) key value
SimpleDB - PUT
SimpleDB - GET
you pay bandwidth :)
Oh yes, $$
• first GB data IN free, 0.10$ after
• first GB data OUT free, 0.17$ or less after
• first GB stored is free, 0.25GB/month after
So, PUT again
+
=
Attribute values are always arrays
< Key
< Value
Attribute >
}Attribute value >
Array
Even if there’s only one value!!
Select
• Sort
• Multiple conditions
• Understands only strings!
• So you need to think when you store your data
Gems
• hungryblank-aws_sdb_bare (github)very low level one to one mapping with SimpleDB calls
• right_aws high level, active recordish api and an hash api
• aws-sdb not any more mantained but still working
SimpleDB - Cons
• Eventual Consistency - Data is not immediately propagated across all nodes… the latency is usually around a second
• Latency specially if you’re not on ec2
• Protocol - if compared with json stores
• Only strings, lexicographical string only
SimpleDB - Pros
• Is basically free to try out
• Everything is indexed
• Distributed
• Replicated
• Completely hosted on Amazon system
Q?
Paolo Negritwitter @hungryblank