• Save
DynamoDB for PHP sessions
Upcoming SlideShare
Loading in...5
×
 

DynamoDB for PHP sessions

on

  • 5,756 views

Step by step how-to for setting up amazon's dynamoDB as backend for storing PHP sessions. Presented at Greece's AWS Usergroup meetup.

Step by step how-to for setting up amazon's dynamoDB as backend for storing PHP sessions. Presented at Greece's AWS Usergroup meetup.

Statistics

Views

Total Views
5,756
Views on SlideShare
4,317
Embed Views
1,439

Actions

Likes
0
Downloads
0
Comments
0

11 Embeds 1,439

http://labs.spitogatos.gr 751
http://www.newvem.com 606
http://newvem.staging.wpengine.com 65
http://www.slashdocs.com 4
http://www.linkedin.com 4
https://si0.twimg.com 3
http://us-w1.rockmelt.com 2
http://87.248.112.8 1
http://www.newvem.stg 1
http://webcache.googleusercontent.com 1
https://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

DynamoDB for PHP sessions DynamoDB for PHP sessions Presentation Transcript

  • 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 cloudSticky sessions?Memcache?MySQL?Redis?Enter DynamoDB:Highly available – Consistently performingPersistentAWS SDK now includes drop in PHP sessionhandler 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 SDKInstall the latest version of the SDK on your web serverimage - 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
  • Instantiaterequire_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.inisession.save_handler = userauto_prepend_file = /path-to/dynamosessions.php Restart web server Test Snapshot fresh AMI 8
  • ConsiderationsEstimate read/write throughput requirements Validate post go liveDoes your application need locking? By defaultphp 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