SlideShare una empresa de Scribd logo
1 de 9
DynamoDB for PHP Session Storage

            25 April 2012




                                     Andreas Chatzakis
                                   @achatzakis on twitter
                                            AWSUG Greece
                      Not affiliated with, sponsored or endorsed by AWS
Sessions in the cloud


Sticky sessions?
Memcache?
MySQL?
Redis?
Enter DynamoDB:
Highly available – Consistently performing
Persistent
AWS SDK now includes drop in PHP session
handler replacement

                                               2
Create a user




            3
Create a table




             4
Give Permissions

{   "Statement": [
     { "Sid": "Stmt1335183103764",
       "Action": [
         "dynamodb:BatchGetItem",
         "dynamodb:DeleteItem",
         "dynamodb:DescribeTable",
         "dynamodb:GetItem",
         "dynamodb:PutItem",
         "dynamodb:Query",
         "dynamodb:Scan",
         "dynamodb:UpdateItem" ],
       "Effect": "Allow",
       "Resource": [ "arn:aws:dynamodb:us-east-
1:846544612030:table/php-sessions-test"]
     } ] }




                                                                 5
Install & Configure SDK

Install the latest version of the SDK on your web server
image - http://aws.amazon.com/sdkforphp/
 Update config.inc.php with
  the credentials of the user we created in step 1
  the default-cache-config parameter (we went for apc, as it is
  already running on our instances.)
  any other parameters depending on your specific setup details
  (the file is well documented)




                                                                  6
Instantiate

require_once '/path-to/AWSSDKforPHP/sdk.class.php';
// Instantiate the Amazon DynamoDB client.

$dynamodb = new AmazonDynamoDB();
$dynamodb->set_hostname("https://dynamodb.us-east-1.amazonaws.com");

// Register the DynamoDB Session Handler.
$handler = $dynamodb->register_session_handler(array(
    'table_name'           => 'php-sessions-test',
    'hash_key'             => 'id',
    'session_lifetime'     => 0,
    'consistent_reads'     => true,
    'session_locking'      => false,
    'max_lock_wait_time'   => 15,
    'min_lock_retry_utime' => 5000,
    'max_lock_retry_utime' => 50000,
));




                                                                       7
Update php.ini



session.save_handler = user
auto_prepend_file = /path-to/dynamosessions.php



 Restart web server
 Test
 Snapshot fresh AMI




                                                    8
Considerations


Estimate read/write throughput requirements
 Validate post go live
Does your application need locking? By default
php implements pessimistic locking.
 The class provided by AWS supports it
 Configure it to FALSE if you dont need it (this will
 decrease costs and increase performance).
 Thorough testing would be required to validate your
 selection.




                                                        9

Más contenido relacionado

La actualidad más candente

Adverbs r.v.
Adverbs r.v.Adverbs r.v.
Adverbs r.v.
Papraiz
 
Relative pronouns
Relative pronounsRelative pronouns
Relative pronouns
Rick Zepeda
 
Coordinating conjunctions[1]4th grade
Coordinating conjunctions[1]4th gradeCoordinating conjunctions[1]4th grade
Coordinating conjunctions[1]4th grade
Nancy McEwen
 
Similes for Second Graders
Similes for Second GradersSimiles for Second Graders
Similes for Second Graders
gherm6
 
Idioms for Second Graders
Idioms for Second GradersIdioms for Second Graders
Idioms for Second Graders
gherm6
 

La actualidad más candente (20)

Adverbs r.v.
Adverbs r.v.Adverbs r.v.
Adverbs r.v.
 
Linking expressions
Linking expressionsLinking expressions
Linking expressions
 
English idioms
English idiomsEnglish idioms
English idioms
 
Suffix Rules Made a Little Simpler
Suffix Rules Made a Little SimplerSuffix Rules Made a Little Simpler
Suffix Rules Made a Little Simpler
 
Parts of the body gr 1
Parts of the body gr 1Parts of the body gr 1
Parts of the body gr 1
 
Noun Clauses - Siti ayu nur ain
Noun Clauses - Siti ayu nur ain Noun Clauses - Siti ayu nur ain
Noun Clauses - Siti ayu nur ain
 
Relative pronouns
Relative pronounsRelative pronouns
Relative pronouns
 
SUBJECT VERB AGREEMENT 5
SUBJECT VERB AGREEMENT 5SUBJECT VERB AGREEMENT 5
SUBJECT VERB AGREEMENT 5
 
Continents and Oceans
Continents and OceansContinents and Oceans
Continents and Oceans
 
Cause and effect
Cause and effectCause and effect
Cause and effect
 
Capitalization Rules
Capitalization RulesCapitalization Rules
Capitalization Rules
 
And, But, So, Before,
And, But, So, Before,And, But, So, Before,
And, But, So, Before,
 
First conditional
First conditionalFirst conditional
First conditional
 
Coordinating conjunctions[1]4th grade
Coordinating conjunctions[1]4th gradeCoordinating conjunctions[1]4th grade
Coordinating conjunctions[1]4th grade
 
Similes for Second Graders
Similes for Second GradersSimiles for Second Graders
Similes for Second Graders
 
1st grade energy
1st grade energy1st grade energy
1st grade energy
 
Palli Sanchay Bank Ordinance, 2014
Palli Sanchay Bank Ordinance, 2014Palli Sanchay Bank Ordinance, 2014
Palli Sanchay Bank Ordinance, 2014
 
Idioms for Second Graders
Idioms for Second GradersIdioms for Second Graders
Idioms for Second Graders
 
Animals Book.Ppt
Animals Book.PptAnimals Book.Ppt
Animals Book.Ppt
 
Shapes shapes-everywhere
Shapes shapes-everywhereShapes shapes-everywhere
Shapes shapes-everywhere
 

Similar a DynamoDB for PHP sessions

Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
Marcelo Pinheiro
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
Amazon Web Services Korea
 

Similar a DynamoDB for PHP sessions (20)

Richard Cole of Amazon Gives Lightning Tallk at BigDataCamp
Richard Cole of Amazon Gives Lightning Tallk at BigDataCampRichard Cole of Amazon Gives Lightning Tallk at BigDataCamp
Richard Cole of Amazon Gives Lightning Tallk at BigDataCamp
 
AutoScaling and Drupal
AutoScaling and DrupalAutoScaling and Drupal
AutoScaling and Drupal
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend framework
 
(BDT208) A Technical Introduction to Amazon Elastic MapReduce
(BDT208) A Technical Introduction to Amazon Elastic MapReduce(BDT208) A Technical Introduction to Amazon Elastic MapReduce
(BDT208) A Technical Introduction to Amazon Elastic MapReduce
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Architecting cloud
Architecting cloudArchitecting cloud
Architecting cloud
 
How to improve lambda cold starts
How to improve lambda cold startsHow to improve lambda cold starts
How to improve lambda cold starts
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
Heavy Web Optimization: Backend
Heavy Web Optimization: BackendHeavy Web Optimization: Backend
Heavy Web Optimization: Backend
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
 
How to ensure Presto scalability 
in multi use case
How to ensure Presto scalability 
in multi use case How to ensure Presto scalability 
in multi use case
How to ensure Presto scalability 
in multi use case
 
Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...
 

Más de Andreas Chatzakis (6)

ElasticSearch on AWS - Real Estate portal case study (Spitogatos.gr)
ElasticSearch on AWS - Real Estate portal case study (Spitogatos.gr) ElasticSearch on AWS - Real Estate portal case study (Spitogatos.gr)
ElasticSearch on AWS - Real Estate portal case study (Spitogatos.gr)
 
Newvem Community - Cloud Management
Newvem Community - Cloud ManagementNewvem Community - Cloud Management
Newvem Community - Cloud Management
 
Scalr Demo
Scalr DemoScalr Demo
Scalr Demo
 
Cloud Management
Cloud ManagementCloud Management
Cloud Management
 
An intro to Amazon Web Services (AWS)
An intro to Amazon Web Services (AWS)An intro to Amazon Web Services (AWS)
An intro to Amazon Web Services (AWS)
 
AWS case study: real estate portal
AWS case study: real estate portalAWS case study: real estate portal
AWS case study: real estate portal
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

DynamoDB for PHP sessions

  • 1. DynamoDB for PHP Session Storage 25 April 2012 Andreas Chatzakis @achatzakis on twitter AWSUG Greece Not affiliated with, sponsored or endorsed by AWS
  • 2. Sessions in the cloud Sticky sessions? Memcache? MySQL? Redis? Enter DynamoDB: Highly available – Consistently performing Persistent AWS SDK now includes drop in PHP session handler replacement 2
  • 5. Give Permissions { "Statement": [ { "Sid": "Stmt1335183103764", "Action": [ "dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:DescribeTable", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:Scan", "dynamodb:UpdateItem" ], "Effect": "Allow", "Resource": [ "arn:aws:dynamodb:us-east- 1:846544612030:table/php-sessions-test"] } ] } 5
  • 6. Install & Configure SDK Install the latest version of the SDK on your web server image - http://aws.amazon.com/sdkforphp/ Update config.inc.php with the credentials of the user we created in step 1 the default-cache-config parameter (we went for apc, as it is already running on our instances.) any other parameters depending on your specific setup details (the file is well documented) 6
  • 7. Instantiate require_once '/path-to/AWSSDKforPHP/sdk.class.php'; // Instantiate the Amazon DynamoDB client. $dynamodb = new AmazonDynamoDB(); $dynamodb->set_hostname("https://dynamodb.us-east-1.amazonaws.com"); // Register the DynamoDB Session Handler. $handler = $dynamodb->register_session_handler(array( 'table_name' => 'php-sessions-test', 'hash_key' => 'id', 'session_lifetime' => 0, 'consistent_reads' => true, 'session_locking' => false, 'max_lock_wait_time' => 15, 'min_lock_retry_utime' => 5000, 'max_lock_retry_utime' => 50000, )); 7
  • 8. Update php.ini session.save_handler = user auto_prepend_file = /path-to/dynamosessions.php Restart web server Test Snapshot fresh AMI 8
  • 9. Considerations Estimate read/write throughput requirements Validate post go live Does your application need locking? By default php implements pessimistic locking. The class provided by AWS supports it Configure it to FALSE if you dont need it (this will decrease costs and increase performance). Thorough testing would be required to validate your selection. 9