32
Amazon SimpleDB A quick intro Paolo Negri twitter @hungryblank

SimpleDb, an introduction

Embed Size (px)

DESCRIPTION

An introduction to Amazon AWS SimpleDB, I gave this talk at the Ruby on Rails usergroup meeting of june 2009

Citation preview

Page 1: SimpleDb, an introduction

Amazon SimpleDBA quick intro

Paolo Negritwitter @hungryblank

Page 2: SimpleDb, an introduction

DB

Page 3: SimpleDb, an introduction

DB?

•SimpleDB

•CouchDB

•MongoDB

Page 4: SimpleDb, an introduction

DB?

http://www.flickr.com/photos/zheem/3091325244/

Page 5: SimpleDb, an introduction

Key Value store?

http://www.flickr.com/photos/wdwbarber/1338954161/

Page 6: SimpleDb, an introduction

A bit like...

• BigTable

• HyperTable

• Redis

• TokyoCabinet

• ...

Page 7: SimpleDb, an introduction

Different Shades

DB >

KV > http://www.flickr.com/photos/dey/11717609/

Page 8: SimpleDb, an introduction

CommonalitiesSchema less

NOJust store your data

Page 9: SimpleDb, an introduction

Commonalities

•No transactions

•No relations

•No datatypes (some)

Page 10: SimpleDb, an introduction

Fast0.7 seconds to store 1 million records

http://www.flickr.com/photos/donsolo/1405885541/

(TokyoCabinet)

Page 11: SimpleDb, an introduction

Big datasets

SimpleDB 1.000.000.000attributes/domain * 100 domains

http://www.flickr.com/photos/digitalart/2101765353/

Page 12: SimpleDb, an introduction

Key ValueA

data

D

data

H1

data

A6

data

< Key

< Value

Page 13: SimpleDb, an introduction

SimpleDB

< Key

< Value

Attribute >

}Attribute value >

AT W

data

data

Page 14: SimpleDb, an introduction

SimpleDB

Nested hash of strings

Page 15: SimpleDb, an introduction

SimpleDB

• Only strings

• No schema (no attribute declaration)

• up to 256 attributes per item

• EVERYTHING INDEXED

Page 16: SimpleDb, an introduction

SimpleDB

• 1024 K max length

• Any UT8 character that is valid in XML docs can be used

< Key

WAttribute >

Attribute value >

Page 17: SimpleDb, an introduction

SimpleDB

• 1.000.000.000 attributes per domain

• 100 domains per account

• you can have more than one account

Page 18: SimpleDb, an introduction

SimpleDB

SOAP protocol<wtf>wtf</wtf>

http://www.flickr.com/photos/rescuedog/2242215507

Page 19: SimpleDb, an introduction

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=...

Page 20: SimpleDb, an introduction

SimpleDB

HostSimpleDB

requestREST or XML

responseXML

Page 21: SimpleDb, an introduction

SimpleDB Requests

• create/delete domain

• put/get/delete (selectively) attributes

• and... SELECT

Page 22: SimpleDb, an introduction

SimpleDB

• Up to 10GB big

• Up to 1.000.000.000 attributes stored

Domain: a container of (nested) key value

Page 23: SimpleDb, an introduction

SimpleDB - PUT

Page 24: SimpleDb, an introduction

SimpleDB - GET

you pay bandwidth :)

Page 25: SimpleDb, an introduction

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

Page 26: SimpleDb, an introduction

So, PUT again

+

=

Page 27: SimpleDb, an introduction

Attribute values are always arrays

< Key

< Value

Attribute >

}Attribute value >

Array

Even if there’s only one value!!

Page 28: SimpleDb, an introduction

Select

• Sort

• Multiple conditions

• Understands only strings!

• So you need to think when you store your data

Page 29: SimpleDb, an introduction

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

Page 30: SimpleDb, an introduction

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

Page 31: SimpleDb, an introduction

SimpleDB - Pros

• Is basically free to try out

• Everything is indexed

• Distributed

• Replicated

• Completely hosted on Amazon system

Page 32: SimpleDb, an introduction

Q?

Paolo Negritwitter @hungryblank