SlideShare una empresa de Scribd logo
1 de 49
#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 PHP
require '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');
Amazon DynamoDB
Website hosted on
AWS Elastic Beanstalk


Pet profiles and appointments
stored 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_name' => 'sessions'
));

// Use PHP sessions like normal
session_start();
$_SESSION[‘abc'] = 'bar';
session_write_close();
<1KB
Part 2: Triage
  Let's query!
Puppies   Kittens   Old dogs   Old cats   Hefty cats
• 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')
          )
Faster, but
only operates
   on keys


Query           Scan
Puppies           Kittens   Old dogs           Old cats    Hefty cats




      Age LT 1                     Age GT 10              Species EQ Cat
AND Species IN [Cat, Dog]    AND Species IN [Cat, Dog]     Weight GT 20
No,
               endforeach

                                            Yes, send more

ScanIterator                Yield results
Simple Iterator
$tables = $db->getIterator('ListTables', array(
    'Limit' => 25
));

foreach ($tables as $table) {
    echo $table . PHP_EOL;
}
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'
        )
    )
));
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
}
Demo: Iterators
$client->addSubscriber(new CommandAnnouncerListener());
Events – Example Plugin
class 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";
    }
}
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'] = array('S' => date('Ymd'));
    $batch->add($db->getCommand('PutItem', array(
         'TableName' => 'Appointments',
         'Item'      => $pet
    )));
}

$batch->flush();
Demo: Batching
$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();
We are sincerely eager to      #reinvent
 hear your feedback on this
presentation and on re:Invent.

 Please fill out an evaluation
   form when you have a
            chance.

Más contenido relacionado

La actualidad más candente

Deep Dive - Advanced Usage of the AWS CLI
Deep Dive - Advanced Usage of the AWS CLIDeep Dive - Advanced Usage of the AWS CLI
Deep Dive - Advanced Usage of the AWS CLIAmazon Web Services
 
Amazon Web Services for PHP Developers
Amazon Web Services for PHP DevelopersAmazon Web Services for PHP Developers
Amazon Web Services for PHP DevelopersJeremy Lindblom
 
Amazon Cloud Services and Zend Framework
Amazon Cloud Services and Zend FrameworkAmazon Cloud Services and Zend Framework
Amazon Cloud Services and Zend FrameworkShahar Evron
 
Amazon Route53へのドメイン移管
Amazon Route53へのドメイン移管Amazon Route53へのドメイン移管
Amazon Route53へのドメイン移管Jin k
 
Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013
Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013
Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013Amazon Web Services
 
Lightweight wrapper for Hive on Amazon EMR
Lightweight wrapper for Hive on Amazon EMRLightweight wrapper for Hive on Amazon EMR
Lightweight wrapper for Hive on Amazon EMRShinji Tanaka
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Kris Wallsmith
 
Powershell for Log Analysis and Data Crunching
 Powershell for Log Analysis and Data Crunching Powershell for Log Analysis and Data Crunching
Powershell for Log Analysis and Data CrunchingMichelle D'israeli
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony TechniquesKris Wallsmith
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUGBen Scofield
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers StealBen Scofield
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application frameworktechmemo
 

La actualidad más candente (20)

Deep Dive - Advanced Usage of the AWS CLI
Deep Dive - Advanced Usage of the AWS CLIDeep Dive - Advanced Usage of the AWS CLI
Deep Dive - Advanced Usage of the AWS CLI
 
Amazon Web Services for PHP Developers
Amazon Web Services for PHP DevelopersAmazon Web Services for PHP Developers
Amazon Web Services for PHP Developers
 
Amazon Cloud Services and Zend Framework
Amazon Cloud Services and Zend FrameworkAmazon Cloud Services and Zend Framework
Amazon Cloud Services and Zend Framework
 
Nubilus Perl
Nubilus PerlNubilus Perl
Nubilus Perl
 
Amazon Route53へのドメイン移管
Amazon Route53へのドメイン移管Amazon Route53へのドメイン移管
Amazon Route53へのドメイン移管
 
Perl Web Client
Perl Web ClientPerl Web Client
Perl Web Client
 
Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013
Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013
Becoming a Command Line Expert with the AWS CLI (TLS304) | AWS re:Invent 2013
 
Lightweight wrapper for Hive on Amazon EMR
Lightweight wrapper for Hive on Amazon EMRLightweight wrapper for Hive on Amazon EMR
Lightweight wrapper for Hive on Amazon EMR
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
Not your Grandma's XQuery
Not your Grandma's XQueryNot your Grandma's XQuery
Not your Grandma's XQuery
 
Play á la Rails
Play á la RailsPlay á la Rails
Play á la Rails
 
Powershell for Log Analysis and Data Crunching
 Powershell for Log Analysis and Data Crunching Powershell for Log Analysis and Data Crunching
Powershell for Log Analysis and Data Crunching
 
XQuery Rocks
XQuery RocksXQuery Rocks
XQuery Rocks
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUG
 
Neatly folding-a-tree
Neatly folding-a-treeNeatly folding-a-tree
Neatly folding-a-tree
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
 
XQuery in the Cloud
XQuery in the CloudXQuery in the Cloud
XQuery in the Cloud
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application framework
 

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

An introduction to property-based testing
An introduction to property-based testingAn introduction to property-based testing
An introduction to property-based testingVincent Pradeilles
 
Power shell voor developers
Power shell voor developersPower shell voor developers
Power shell voor developersDennis Vroegop
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersIan Barber
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScriptniklal
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with GroovyArturo Herrero
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackVic Metcalfe
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionIban Martinez
 
Hidden treasures of Ruby
Hidden treasures of RubyHidden treasures of Ruby
Hidden treasures of RubyTom Crinson
 
The Art of Transduction
The Art of TransductionThe Art of Transduction
The Art of TransductionDavid Stockton
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)xSawyer
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方techmemo
 
Stop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScriptStop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScriptRyan Anklam
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6garux
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRaimonds Simanovskis
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Masahiro Nagano
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsBastian Feder
 
PHP record- with all programs and output
PHP record- with all programs and outputPHP record- with all programs and output
PHP record- with all programs and outputKavithaK23
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 

Similar a TLS305 Using DynamoDB with the AWS SDK for PHP - AWS re: Invent 2012 (20)

An introduction to property-based testing
An introduction to property-based testingAn introduction to property-based testing
An introduction to property-based testing
 
Power shell voor developers
Power shell voor developersPower shell voor developers
Power shell voor developers
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find Fraudsters
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introduction
 
Smelling your code
Smelling your codeSmelling your code
Smelling your code
 
Hidden treasures of Ruby
Hidden treasures of RubyHidden treasures of Ruby
Hidden treasures of Ruby
 
The Art of Transduction
The Art of TransductionThe Art of Transduction
The Art of Transduction
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方
 
Stop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScriptStop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScript
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
PHPSpec BDD for PHP
PHPSpec BDD for PHPPHPSpec BDD for PHP
PHPSpec BDD for PHP
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
 
PHP record- with all programs and output
PHP record- with all programs and outputPHP record- with all programs and output
PHP record- with all programs and output
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 

Más de Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 

Más de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

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

  • 2. AWS SDK for PHP 2
  • 3. re: • Faster and more flexible • More open source
  • 4. • Foundation of the AWS SDK • Symfony2 EventDispatcher http://guzzlephp.org
  • 5. Getting Started with the AWS SDK for PHP require '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.
  • 7.
  • 9.
  • 10.
  • 11. Website hosted on AWS Elastic Beanstalk Pet profiles and appointments stored in Amazon DynamoDB
  • 12. Part 1: Outbreak Time to scale up!
  • 13.
  • 14.
  • 15.
  • 16. Session Handler – Basic Usage // Register the handler $db = $aws->get('dynamodb'); $db->registerSessionHandler(array( 'table_name' => 'sessions' )); // Use PHP sessions like normal session_start(); $_SESSION[‘abc'] = 'bar'; session_write_close();
  • 17.
  • 18.
  • 19. <1KB
  • 20. Part 2: Triage Let's query!
  • 21. Puppies Kittens Old dogs Old cats Hefty cats
  • 22. • 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') )
  • 23. Faster, but only operates on keys Query Scan
  • 24. Puppies Kittens Old dogs Old cats Hefty cats Age LT 1 Age GT 10 Species EQ Cat AND Species IN [Cat, Dog] AND Species IN [Cat, Dog] Weight GT 20
  • 25.
  • 26. No, endforeach Yes, send more ScanIterator Yield results
  • 27. Simple Iterator $tables = $db->getIterator('ListTables', array( 'Limit' => 25 )); foreach ($tables as $table) { echo $table . PHP_EOL; }
  • 28. 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' ) ) ));
  • 29. 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 }
  • 31.
  • 33. Events – Example Plugin class 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"; } }
  • 35.
  • 36. Part 3: Vaccinate Push the bits!
  • 41.
  • 42. 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();
  • 43.
  • 45.
  • 46.
  • 47. $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();
  • 48.
  • 49. We are sincerely eager to #reinvent hear your feedback on this presentation and on re:Invent. Please fill out an evaluation form when you have a chance.