Your SlideShare is downloading. ×
  • Like
  • Save
DynamoDB for PHP sessions
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

DynamoDB for PHP sessions


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.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 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 cloudSticky sessions?Memcache?MySQL?Redis?Enter DynamoDB:Highly available – Consistently performingPersistentAWS SDK now includes drop in PHP sessionhandler replacement 2
  • 3. Create a user 3
  • 4. Create a table 4
  • 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 SDKInstall the latest version of the SDK on your web serverimage - Update 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. Instantiaterequire_once /path-to/AWSSDKforPHP/sdk.class.php;// Instantiate the Amazon DynamoDB client.$dynamodb = new AmazonDynamoDB();$dynamodb->set_hostname("");// 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.inisession.save_handler = userauto_prepend_file = /path-to/dynamosessions.php Restart web server Test Snapshot fresh AMI 8
  • 9. 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