#reinvent
AWS SDK for PHP 2
re:• Faster and more flexible• More open source
• Foundation of the AWS SDK• Symfony2 EventDispatcher    http://guzzlephp.org
Getting Started with the AWS SDK for PHPrequire vendor/autoload.php;$aws = AwsCommonAws::factory(array(    key    => your-...
Amazon DynamoDB
Website hosted onAWS Elastic BeanstalkPet profiles and appointmentsstored in Amazon DynamoDB
Part 1: Outbreak Time to scale up!
Session Handler – Basic Usage// Register the handler$db = $aws->get(dynamodb);$db->registerSessionHandler(array(    table_...
<1KB
Part 2: Triage  Lets query!
Puppies   Kittens   Old dogs   Old cats   Hefty cats
• S: Id   array(            Id        =>   array(S   =>   000012),            Species   =>   array(S   =>   Cat),         ...
Faster, butonly operates   on keysQuery           Scan
Puppies           Kittens   Old dogs           Old cats    Hefty cats      Age LT 1                     Age GT 10         ...
No,               endforeach                                            Yes, send moreScanIterator                Yield re...
Simple Iterator$tables = $db->getIterator(ListTables, array(    Limit => 25));foreach ($tables as $table) {    echo $table...
Scan Iterators – Example$youngPets = $db->getIterator(Scan, array(    TableName => Pets,    ScanFilter => array(        sp...
Scan Iterators – Combining and Iterating$atRiskPets = new AppendIterator();$atRiskPets->append($youngPets);$atRiskPets->ap...
Demo: Iterators
$client->addSubscriber(new CommandAnnouncerListener());
Events – Example Pluginclass CommandAnnouncerListener implements    EventSubscriberInterface{    public static function ge...
Demo: Iterators
Part 3: Vaccinate   Push the bits!
Batch System
(Strategy Pattern)
(Decorator Pattern)
(Builder Pattern)
DynamoDB WriteRequestBatch – Usage$batch = WriteRequestBatch::factory($db);foreach ($atRiskPets as $pet) {    $pet[date] =...
Demo: Batching
$iterator = $db->getIterator(Scan, array([…]));$batch = WriteRequestBatch::factory($db);foreach ($iterator as $pet) {    $...
We are sincerely eager to      #reinvent hear your feedback on thispresentation and on re:Invent. Please fill out an evalu...
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012
Upcoming SlideShare
Loading in …5
×

TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012

8,209 views

Published on

Learn how to work with Amazon DynamoDB using the AWS SDK for PHP. Attendees learn about the AWS SDK for PHP including how to install and configure the SDK and how to perform operations with DynamoDB. Advanced discussion topics include tips for effective DynamoDB usage, request batching, performance tuning, configuring event listeners, and setting up the included DynamoDB session handler for session storage.

0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
8,209
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
0
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012

  1. 1. #reinvent
  2. 2. AWS SDK for PHP 2
  3. 3. re:• Faster and more flexible• More open source
  4. 4. • Foundation of the AWS SDK• Symfony2 EventDispatcher http://guzzlephp.org
  5. 5. Getting Started with the AWS SDK for PHPrequire vendor/autoload.php;$aws = AwsCommonAws::factory(array( key => your-aws-access-key-id, secret => your-aws-secret-access-key, region => us-west-2));$db = $aws->get(dynamodb);$s3 = $aws->get(s3);
  6. 6. Amazon DynamoDB
  7. 7. Website hosted onAWS Elastic BeanstalkPet profiles and appointmentsstored in Amazon DynamoDB
  8. 8. Part 1: Outbreak Time to scale up!
  9. 9. Session Handler – Basic Usage// Register the handler$db = $aws->get(dynamodb);$db->registerSessionHandler(array( table_name => sessions));// Use PHP sessions like normalsession_start();$_SESSION[‘abc] = bar;session_write_close();
  10. 10. <1KB
  11. 11. Part 2: Triage Lets query!
  12. 12. Puppies Kittens Old dogs Old cats Hefty cats
  13. 13. • S: Id array( Id => array(S => 000012), Species => array(S => Cat), Name => array(S => Fluffy), Owner => array(S => Yifei), Age => array(N => 11), Weight => array(N => 20) )
  14. 14. Faster, butonly operates on keysQuery Scan
  15. 15. Puppies Kittens Old dogs Old cats Hefty cats Age LT 1 Age GT 10 Species EQ CatAND Species IN [Cat, Dog] AND Species IN [Cat, Dog] Weight GT 20
  16. 16. No, endforeach Yes, send moreScanIterator Yield results
  17. 17. Simple Iterator$tables = $db->getIterator(ListTables, array( Limit => 25));foreach ($tables as $table) { echo $table . PHP_EOL;}
  18. 18. Scan Iterators – Example$youngPets = $db->getIterator(Scan, array( TableName => Pets, ScanFilter => array( species => array( AttributeValueList => array(array(S => Dog), array(S => Cat)), ComparisonOperator => IN ), age => array( AttributeValueList => array(array(N => 1), ComparisonOperator => LT ) )));
  19. 19. Scan Iterators – Combining and Iterating$atRiskPets = new AppendIterator();$atRiskPets->append($youngPets);$atRiskPets->append($oldPets);$atRiskPets->append($heftyCats);foreach ($atRiskPets as $pet) { echo "Vaccinate {$pet[Name][S]}.n"; // @TODO Create an appointment}
  20. 20. Demo: Iterators
  21. 21. $client->addSubscriber(new CommandAnnouncerListener());
  22. 22. Events – Example Pluginclass CommandAnnouncerListener implements EventSubscriberInterface{ public static function getSubscribedEvents() { return array(command.before_send => array( onCommandBeforeSend) ); } public function onCommandBeforeSend(Event $event) { $commandName = $event[command]->getName(); echo "Executing the {$commandName} operation.n"; }}
  23. 23. Demo: Iterators
  24. 24. Part 3: Vaccinate Push the bits!
  25. 25. Batch System
  26. 26. (Strategy Pattern)
  27. 27. (Decorator Pattern)
  28. 28. (Builder Pattern)
  29. 29. DynamoDB WriteRequestBatch – Usage$batch = WriteRequestBatch::factory($db);foreach ($atRiskPets as $pet) { $pet[date] = array(S => date(Ymd)); $batch->add($db->getCommand(PutItem, array( TableName => Appointments, Item => $pet )));}$batch->flush();
  30. 30. Demo: Batching
  31. 31. $iterator = $db->getIterator(Scan, array([…]));$batch = WriteRequestBatch::factory($db);foreach ($iterator as $pet) { $batch->add($db->getCommand(PutItem, array( TableName => Appointments, Item => $pet )));}$batch->flush();
  32. 32. We are sincerely eager to #reinvent hear your feedback on thispresentation and on re:Invent. Please fill out an evaluation form when you have a chance.

×